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

一个新手
Release: 2017-09-19 09:28:37
Original
1590 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template