基本语法
text-overflow的使用需配合hight,over-flow:hidden;white-space:nowrap;三个属性共同使用
text-overflow: clip;ellipsis;string
clip: 直接隐藏不显示
ellipse: 用… 三个点来表示溢出的文字 (常用)
string:可自定义符号来表示放不下的字符
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.tf{
width: 100px;
height:50px;
border:1px solid black;
overflow: hidden;
text-overflow: clip;/*如果只是单纯的隐藏的话,加不加这句话效果都一样 height+overflow就可对溢出的文字直接隐藏*/
}
.tf1{
width: 100px;
border:1px solid black;
overflow: hidden;
text-overflow: ellipsis;
-webkit-text-overflow: ellipsis;
white-space: nowrap;
/*若使用ellipsis属性
text-overflow:ellipsis; overflow: hidden;white-space: nowrap;
这三个属性缺一不可
*/
}
</style>
</head>
<body>
<div class="tf">
新浪网新闻中心是新浪网最重要的频道之一,24小时滚动报道国内、国际及社会新闻。每日编发新闻数以万计。
</div>
<div class="tf1">
新浪网新闻中心是新浪网最重要的频道之一,24小时滚动报道国内、国际及社会新闻。每日编发新闻数以万计。
</div>
</body>
</html>