惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
人人都是产品经理
人人都是产品经理
H
Help Net Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
T
Troy Hunt's Blog
宝玉的分享
宝玉的分享
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Schneier on Security
Vercel News
Vercel News
Stack Overflow Blog
Stack Overflow Blog
B
Blog
The GitHub Blog
The GitHub Blog
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The Register - Security
The Register - Security
F
Fortinet All Blogs
爱范儿
爱范儿
L
LINUX DO - 热门话题
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
Last Week in AI
Last Week in AI
D
Docker
Application and Cybersecurity Blog
Application and Cybersecurity Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Spread Privacy
Spread Privacy
The Hacker News
The Hacker News
Hacker News: Ask HN
Hacker News: Ask HN
Project Zero
Project Zero
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
P
Privacy International News Feed
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Securelist
Google Online Security Blog
Google Online Security Blog
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
Martin Fowler
Martin Fowler

博客园 - WEBBER

SQL语句中使用变量作为条件。遇到NULL时怎么写 checkbox单选 T4MVC Documentation page(转) ASIHTTPRequest 详解, http 请求终结者 (转) ASP.NET版Memcached监控工具(转) 完整的DataTable和list转换 老外写的(转) 技巧:使用User Control做HTML生成(转) Silverlight跟ASP.NET之間要如何溝通querystring(转) asp.net取得Silverlight中的值(转) IIS6 Silverlight部署經驗(转) c#四种eval方法(转) - WEBBER - 博客园 sql2005数据同步技术(数据订阅,发布)转 C# 域用户操作(转) 看到了一些面试题,发给大家,看看多少人能都全回答上来 Membership角色与权限管理 (转) 我的跳槽求职经验谈(转) IHttpHandler的妙用(2):防盗链!我的资源只有我的用户才能下载 (转) JavaScript组件之JQuery(A~Z)教程(基于Asp.net运行环境)(转) 说说大型高并发高负载网站的系统架构 (转)
一行内文本超出指定宽度溢出的处理
WEBBER · 2008-07-08 · via 博客园 - WEBBER

转自:http://blog.163.com/pcboby@126/blog/static/31201400200802115013555/
看到标题你一定很容易就会想到截断文字加“...”的做法。哈哈,就是这样。其实写这篇日志也只是把这样方法做个记录,因为好像还有很多人不记得遇到这样的情况该如何处理。

  我们也可以参考52CSS.com以前的文章:
  CSS对文字溢出时的自动隐藏处理http://www.webjx.com/htmldata/2007-05-05/1178374126.html
  如何设置列表(li)超出部分显示省略号http://www.webjx.com/htmldata/2007-05-05/1178374241.html

  一般的文字截断(适用于内联与块):

.text-overflow {
display:block;/*内联对象需加*/
width:31em;
word-break:keep-all;/* 不换行 */
white-space:nowrap;/* 不换行 */
overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/
}

  对于表格文字溢出的定义:

table{
width:30em;
table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */
}
td{
width:100%;
word-break:keep-all;/* 不换行 */
white-space:nowrap;/* 不换行 */
overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用。*/
}

  需要你注意的是,这个东东只对单行的文字的效,如果你想把它用在多行上,也只有第一行有作用的。 这个写法只有IE会有“...”,其它的浏览器文本超出指定宽度时会隐藏。