clip:当内联内容溢出块容器时,将溢出部分裁切掉。

ellipsis:当内联内容溢出块容器时,将溢出部分替换为(...)。

当块容器 <' overflow '> 为非visible时,定义内联内容溢出其块容器是否截断或者添加(...)及自定义字符
要使得 <' text-overflow '> 属性生效,块容器必须显式定义 <' overflow '> 为非visible值,同时显式或者隐式的定义 <' width '> 为非auto值, <' white-space '> 为nowrap值。
我们将text-overflow生效必备的3个属性: <' overflow '> , <' width '> 和 <' white-space '> 都直接定义在了内联内容的父级块容器上
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8" />
<title>text-overflow_CSS参考手册_web前端开发参考手册系列</title>
<style>
.test li{margin-top:10px;}
.test .clip p{overflow:hidden;width:200px;white-space:nowrap;text-overflow:clip;}
.test .ellipsis p{overflow:hidden;width:200px;white-space:nowrap;text-overflow:ellipsis;}
</style>
</head>
<body>
<ul class="test">
<li class="clip">
<strong>clip: 直接将溢出的文字裁剪</strong>
<p>测试用文字测试用文字测试用文字测试用文字测试用文字测试用文字</p>
</li>
<li class="ellipsis">
<strong>ellipsis: 将溢出的文字显示省略标记(...)</strong>
<p>测试用文字测试用文字测试用文字测试用文字测试用文字测试用文字</p>
</li>
</ul>
</body>
</html>
方法(此方法Firefox5.0尚不支持):
#test{width:150px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
首先需设置将文本强制在一行内显示,然后将溢出的文本通过overflow:hidden截断,并以text-overflow:ellipsis方式将截断的文本显示为省略号。

原文出处:http://gucong3000.github.io/css-book/properties/user-interface/text-overflow.htm

css3 文本超出后出现省略号的更多相关文章

  1. CSS3 文本超出后显示省略号...

    纯用CSS实现,主要采用代码 overflow:hidden; text-overflow:ellipsis;//这是让文本溢出后,显示成省略号. white-space:nowrap;//禁止自动换 ...

  2. CSS3文本超出容器显示省略号之text-overflow属性

    text-overflow:ellipsis; overflow:hidden; white-space:nowrap; 要想实现文本超出容器时显示省略号,上面3个属性必须同时搭配使用

  3. CSS——文本超出隐藏显示省略号

    文本超出隐藏显示省略号 1.单行文本的溢出显示省略号 overflow: hidden; text-overflow:ellipsis; white-space: nowrap; // overflo ...

  4. css设置内容超出后显示省略号

    1.使用overflow: hidden把超出的内容进行隐藏: 2.然后使用white-space: nowrap设置内容不换行: 3.最后使用text-overflow: ellipsis设置超出内 ...

  5. css文本超出隐藏显示省略号

    p style="width: 300px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;"> 如 ...

  6. css文本超出部分用省略号表示

    以前我在面试中遇到过这个问题,当时没答上来,现在回答一下: 1.设置三个属性: overflow:hidden   (超出部分隐藏) white-space:nowrap    (强制不换行) tex ...

  7. css兼容大部分浏览器的文本超出部分显示省略号

    css之字体多行省略(兼容大部分浏览器) 字体单行显示省略号 <style> .box1{ width: 500px; height: 1.5em; overflow: hidden; t ...

  8. css-文本超出后显示省略号

    1.如果是单行文本: overflow: hidden; text-overflow: ellipsis; white-space: nowrap; 2.如果是多行文本,将文本框高度设为文字行高的倍数 ...

  9. CSS控制文本超出后隐藏并用省略号代替

    一.仅定义text-overflow:ellipsis; 不能实现省略号效果. 二.定义text-overflow:ellipsis; white-space:nowrap; 同样不能实现省略号效果. ...

随机推荐

  1. 《大数据Spark企业级实战 》

    基本信息 作者: Spark亚太研究院   王家林 丛书名:决胜大数据时代Spark全系列书籍 出版社:电子工业出版社 ISBN:9787121247446 上架时间:2015-1-6 出版日期:20 ...

  2. poj1741 bzoj2152

    树分治入门 poj1741是男人八题之一,经典的树分治的题目这里用到的是点分治核心思想是我们把某个点i作为根,把路径分为过点i和不过点i先统计过点i这样的路径数,然后在统计其子树中的答案,这样就不断地 ...

  3. 组合计数(polya计数):SGU 282 Isomorphism

    因为论文的题解写得太好了,直接贴. #include <iostream> #include <cstring> #include <cstdio> using n ...

  4. POJ --- 1164 放苹果

    放苹果 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24947   Accepted: 15887 Description ...

  5. android 更新uI主线程

    http://www.cnblogs.com/wenjiang/p/3180324.html handleMessage 好用

  6. 哈希(2) hash索引

    首先复习:       索引:快速查找的数据结构 1.可以读以下mysql中索引的使用方法,图文并茂.很好理解. http://www.it165.net/database/html/201310/4 ...

  7. Hdu 4312-Meeting point-2 切比雪夫距离,曼哈顿距离,前缀和

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=4312 Meeting point-2 Time Limit: 2000/1000 MS (Java/Ot ...

  8. Bzoj 3236: [Ahoi2013]作业 莫队,分块

    3236: [Ahoi2013]作业 Time Limit: 100 Sec  Memory Limit: 512 MBSubmit: 1113  Solved: 428[Submit][Status ...

  9. MTK Android Driver知识大全

    一.Display 1.lcm 相关概念1.1) MIPI接口:一共有三种接口:DBI(也做CPU或MCU接口).DPI(也叫RGB接口).DSI.在使用DSI接口时,目前75/77都只支持到2条da ...

  10. HW4.19

    public class Solution { public static void main(String[] args) { for(int i = 1; i <= 8; i++) { fo ...