Home  >  Article  >  Web Front-end  >  CSS method to implement single-line and multi-line text overflow and display ellipses

CSS method to implement single-line and multi-line text overflow and display ellipses

一个新手
一个新手Original
2017-09-19 09:28:371581browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn