Home > Article > Web Front-end > CSS method to implement single-line and multi-line text overflow and display ellipses
Code implementation:
<code class="hljs xml"></code><p><span style="color:#009a61">//单行</span></p><p>.single-line{</p><p> width:200px;</p><p> overflow:hidden;</p><p> white-space:nowrap; </p><p> text-overflow:ellipsis;<br/></p><p>}</p><p><span class="hljs-tag"><<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"single-line"</span>></span><span class="hljs-tag"></<span class="hljs-name">p</span>></span></p><p><span style="color:#009a61">//多行</span></p><p>.multiple-line{ </p><p> width:200px; </p><p> display:-webkit-box; </p><p> -webkit-box-orient:vertical; </p><p> -webkit-line-clamp:2; </p><p> overflow:hidden; </p><p>}<br/></p>
Note: Since the CSS extension attribute of WebKit is used, this method is only applicable to WebKit browsers and mobile terminals;
The above is the detailed content of CSS method to implement single-line and multi-line text overflow and display ellipses. For more information, please follow other related articles on the PHP Chinese website!