CSS截取字符串, 多余的字符用省略号显示

WBOY
Release: 2016-06-01 09:53:32
Original
1664 people have browsed it

通常我们截取字符串是用动态语言的函数来处理,本例采用css方法来处理因字符串过长导致的样式不合理的问题。 本人认为这种方法比用函数来截取字符串长度更好。
css代码如下:

<code>a.name{
    line-height: 30px;
    text-align: center;
    text-overflow:ellipsis;//让超出的用...实现
    white-space:nowrap;//禁止换行
    overflow:hidden;//超出的隐藏
    display: block;
}</code>
Copy after login

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