CSS Learning notes: Overflow text ellipsis (text-overflow)

Source: Internet
Author: User

Original: CSS Learning Note: Overflow text ellipsis (text-overflow)

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.