CSS implementation limits the number of words displayed, beyond the display "..."

Source: Internet
Author: User

I. BACKGROUND

In actual projects, we often need to display a specified amount of content in certain areas of certain pages, and the content displayed "..." to beautify the page. Let's take a look at how to achieve this today.

Ii. Steps of implementation

CSS Code

. OV {    white-space:nowrap;     Overflow:hidden;     text-overflow:ellipsis;}

This allows us to achieve this effect, but the restriction is that the content to be displayed can only be on one line and no newline can appear, otherwise it will not work.

Test code

1 <!DOCTYPE HTML>2 <HTML>3     <Head>4     <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">5         <title>Test exceeds display point point</title>6         <styletype= "Text/css">7 . OV{8 White-space:nowrap;9 Overflow:Hidden;Ten Text-overflow:ellipsis; One width:200px; A margin:30px Auto; -             } -         </style> the     </Head> - <Body> -     <Divclass= "ov"> - Test show point Point point of Test show Point Point Test Show Point Point Test Show Point Point Test Show point point testing display points Point test show Point Point Test Show points point testing display point points test show dot point test show Point Point Test Show Point Point Test display point Point point test display dot Point test show point points test show points dot  Dot Dot Point +     </Div> - </Body> + </HTML>

The display results are as follows:

CSS implementation limits the number of words displayed, beyond the display "..."

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.