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 "..."