text-overflow属性怎么用


本文摘自PHP中文网,作者青灯夜游,侵删。

text-overflow属性用于指定当文本溢出包含它的元素时,应该发生的事情。

CSS3 text-overflow属性

作用:text-overflow 属性规定当文本溢出包含元素时发生的事情。

语法:

1

text-overflow: clip|ellipsis|string;

clip:修剪文本。

ellipsis:显示省略符号来代表被修剪的文本。

string:使用给定的字符串来代表被修剪的文本。

注:所有主流浏览器都支持 text-overflow 属性。

CSS3 text-overflow属性的使用示例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<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>将鼠标移动到框内,查看效果.</p>

<div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div>

<br>

<div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div>

</body>

</html>

效果图:

1.gif

本文参考:https://www.html.cn/book/css/properties/user-interface/text-overflow.htm

以上就是text-overflow属性怎么用的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

css3如何设置placeholder的样式

浅谈css3 device-width和width之间的差异

关于老式浏览器兼容html5和css3的问题详解

css3中background-size实现背景图片大小可自定义的几种效果(代码实例 )

css3实现文字折纸效果的方法(代码示例)

css3和h5实现波纹特效实例代码

h5和css3制作一个相册的代码实例

css3是什么

css3 transition-duration属性怎么用

css3是什么技术

更多相关阅读请进入《text-overflow属性》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...