<style type= "Text/css" >
. textoverflow {
width:300px;
Overflow:hidden;
Text-overflow:ellipsis;
White-space:nowrap;
border:1px solid #ddd;
}
</style>
<div class= "Textoverflow" >
Various types of source code, CSS effect codes and common software download. </div>
</div>
</div>
</body>
Because of the need for Web publishing, some places require too long questions plus ellipses. For example: the title limit of 20 Chinese width, beyond the use of ellipses instead. The method used to intercept the program before, but using CSS to intercept more conducive to SEO.
Here's a look at how to use this:
<div class= "title" > Display ellipsis when text overflows in objects </div>
This is an example, in fact we only need to display the following length:
CSS implementation of the page text too long interception ...
The title class should write this:
. title{width:300px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
Description
1, the width must be set, can be adjusted according to the actual needs.
2, White-space:nowrap is prohibited text folding line.
3. Text-overflow Indicates whether an ellipsis is displayed when text overflows, with two values:
Clip: Do not display the ellipsis tag (...). ), but a simple cut.
Ellipsis: Displays ellipsis (...) when text inside an object overflows. )
4, Overflow:hidden indicates that overflow content is hidden.
Example:
#FormatImgID_0 #
Example code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>text-overflow</title>
<body>
<style type= "Text/css" >
Test_demo_clip{text-overflow:clip; overflow:hidden; white-space:nowrap; width:200px; background: #ccc;}
test_demo_ellipsis{text-overflow:ellipsis; overflow:hidden; white-space:nowrap; width:200px; background: #ccc;}
</style>
<div class= "Test_demo_clip" >
Does not display ellipsis, but a simple trimming bar
</div>
<div class= "Test_demo_ellipsis" >
Show ellipsis when text inside an object overflows
</div>
</body>
CSS uses overflow to hide out-of-range content (text is too long hidden)