多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# CSS3 text-overflow 属性 ## 实例 使用 text-overflow 属性: ``` div.test { text-overflow:ellipsis; } ``` 页面底部有更多实例。 ## 浏览器支持 | IE | Firefox | Chrome | Safari | Opera | | --- | --- | --- | --- | --- | 所有主流浏览器都支持 text-overflow 属性。 ## 定义和用法 text-overflow 属性规定当文本溢出包含元素时发生的事情。 | 默认值: | clip | | --- | --- | | 继承性: | no | | --- | --- | | 版本: | CSS3 | | --- | --- | | JavaScript 语法: | _object_.style.textOverflow="ellipsis" | | --- | --- | ## 语法 ``` text-overflow: clip|ellipsis|_string_; ``` | 值 | 描述 | 测试 | | --- | --- | --- | | clip | 修剪文本。 | [测试](/tiy/c.asp?f=css_text-overflow) | | ellipsis | 显示省略符号来代表被修剪的文本。 | [测试](/tiy/c.asp?f=css_text-overflow&p=2) | | _string_ | 使用给定的字符串来代表被修剪的文本。 | ## 亲自试一试 - 实例 [带有 hover 效果的 Text-overflow](/tiy/t.asp?f=css3_text-overflow_hover) 本例演示当光标浮动到元素上时如何显示全部文本。 ``` <!DOCTYPE html> <html> <head> <style> div.test { white-space:nowrap; width:12em; overflow:hidden; border:1px solid #000000; } div.test:hover { text-overflow:inherit; overflow:visible; } </style> </head> <body> <p>如果您把光标移动到下面两个 div 上,就能够看到全部文本。</p> <p>这个 div 使用 "text-overflow:ellipsis" :</p> <div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div> <p>这个 div 使用 "text-overflow:clip":</p> <div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div> </body> </html> ``` ## 相关页面 CSS3 教程:[CSS3 文本效果](/css3/css3_text_effect.asp "CSS3 文本效果")