In CSS3, the basic syntax for the Text-overflow property is as follows:
- Clip: Indicates that the omitted text is not displayed and is simply trimmed.
- Ellipsis: Indicates that an ellipsis is displayed when an object text overflows, and the caret insertion position is the last character.
- Ellipsis-word: Indicates that an ellipsis is displayed when the object text overflows, and the position of the ellipsis insertion is the last word (word).
In fact, the Text-overflow property is used only to determine if an ellipsis is displayed when text overflows, does not have a style-defined function, and to produce an ellipsis effect when overflow, you should define two styles: force the text to appear on one line (white-space : nowrap) and overflow content as hidden (Overflow:hidden), only in this way can the overflow text be displayed as an ellipsis effect .
Case:
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8">5 <title></title>6 <styletype= "Text/css">7 DL{8 width:240px;9 Border:Solid 1px #ccc;Ten } One DT{ A padding:8px 8px; - background:#7fecad; - font-size:13px; the text-align: Left; - Font-weight:Bold; - Color:#71790c; - Margin-bottom:12px; + Border-bottom:Solid 1px #efefef; - } + DD{ A font-size:0.78em; at Height:1.5em; - width:220px; - padding:2px 2px 2px 18px; - margin:2px 0; - White-space:nowrap; - Overflow:Hidden; in Text-overflow:ellipsis; - } to </style> + </Head> - <Body> the <DL> * <DT>Sports News</DT> $ <DD>Asian Games opens in South Korean port city of Incheon, South Korean President Park Geun-hye attends</DD>Panax Notoginseng <DD>On the first day of the Asian Games, the Korean Legion topped the medal table</DD> - <DD>Asian Games Swimming Spectator guide: 21st began Sun Pan 5 showdown between the big PK</DD> the <DD>Asian Games opens in South Korean port city of Incheon, South Korean President Park Geun-hye attends</DD> + <DD>On the first day of the Asian Games, the Korean Legion topped the medal table</DD> A <DD>Asian Games Swimming Spectator guide: 21st began Sun Pan 5 showdown between the big PK</DD> the </DL> + </Body> - </HTML>
Effect:
CSS Learning notes: Overflow text ellipsis (text-overflow)