<pre name="code" class="html"><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>css省略號text-overflow超出溢出顯示省略號</title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<style type="text/css">
*{
padding: 0;
margin: 0;
}
a{
text-decoration: none;
color: #6699ff
}
ul,li{
list-style: none;
text-align: left;
}
#divcss5{
border:1px solid #ff8000;
padding: 10px;
width: 150px;
margin-left: 10px;
margin-top:10px;
}
#divcss5 li{
width: 150px;
height:24px;
line-height: 24px;
font-size: 12px;
color: #6699ff;
text-overflow:ellipsis;
overflow:hidden;
white-space: nowrap;
}
</style>
</head>
<body>
<ul id="divcss5">
<li><a href="#">顯示不完顯示省略號,測試內容</a></li>
<li><a href="#">第二排測試內容超出顯示省</a></li>
<li><a href="#">能顯示完幾個字</a></li>
</ul>
</body>
</html>
text-overflow省略號樣式總結
要想隱藏溢出內容同時又想讓過多內容以省略號樣式顯示,需要用到css overflow,和text-overflow樣式,同時避免文字自動換行我們使用white-space:nowrap標籤強制內容不換行,使用使用注意這幾個CSS樣式和HTML標籤配合使用才能達到多餘文字內容出現省略號樣式