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

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Schneier on Security
The Last Watchdog
The Last Watchdog
Cyberwarzone
Cyberwarzone
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
The Cloudflare Blog
V
V2EX
博客园_首页
博客园 - 聂微东
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
G
GRAHAM CLULEY
T
Tenable Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
SecWiki News
SecWiki News
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
The GitHub Blog
The GitHub Blog
T
Troy Hunt's Blog
博客园 - 【当耐特】
Forbes - Security
Forbes - Security
H
Hacker News: Front Page
A
About on SuperTechFans
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
D
DataBreaches.Net
P
Privacy & Cybersecurity Law Blog
Schneier on Security
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
D
Docker
P
Proofpoint News Feed

博客园 - 挖豆

关于iframe的滚动条,如何去掉水平滚动条或垂直滚动条 javascript得到网址中传递的参数 的处理函数 页面的焦点:window.onfocus javascript 实现随机数 解析 实现随页面滚动的层(最简单效果) 如何用代码设置滚动条的位置? javascript 网页注册快捷键的函数 关于javascript和c#中日期的两点比较--以防在使用ajax时出错 css实现圆角 关于Ajax.net 操作和访问 session application request ajax.net 的使用方法--摘自网上 ArrayList用法 最全的DOS命令集. 如何写批处理文件 读取数据库表的列名,表列的数据类型 在.NET中用MICROSOFT的Excel.Application 部件读取Excel表 ASP内置对象详细介绍 提供一个专业提供连接字符串的网站 Excel连接字符串
CSS中的overflow
挖豆 · 2007-08-22 · via 博客园 - 挖豆

 最开始是用一个函数来计算字数,然后根据大概的长度来切断字符串进行显示,以防止页面错位的出现.

        后来用一段CSS代码来设置错位的处理:

      

text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;

        这段代码可以使超过定义的宽度和高度的时候,末尾以"..."结束显示.

        今天发现其实只要写了overflow:hidden;那么就不会错位了,一定会按CSS中定位的宽和高来显示,多余的都会被隐藏了,而查看源代码却又是完整的字符串.对搜索引擎很有利.在对div,li等元素使用此属性时,都需要设置高度和宽度的,如果不设置就会自动撑大显示区域,而达不到效果了.

        这样做了以后就不用使用切断字符串的函数了.

CSS overflow属性
w3pop.com / 2006-09-26

The overflow property sets what happens if the content of an element overflow its area.
当内容超出其所在元素的区域时overflow属性可以设置应该如何应对。

Inherited: No
继承性:无

举例

可用值

描述
visible The content is not clipped. It renders outside the element
内容不会被省掉。会显示在元素的外面
hidden The content is clipped, but the browser does not display a scroll-bar to see the rest of the content
内容会被省掉,但浏览器不会显示滚动条以用来查看剩余的内容
scroll The content is clipped, but the browser displays a scroll-bar to see the rest of the content
内容被省掉,但浏览器会显示滚动条以用来查看剩余的内容
auto If the content is clipped, the browser should display a scroll-bar to see the rest of the content
如果内容被省掉了,浏览器才会显示出滚动条