Home >Web Front-end >HTML Tutorial >Add ellipses after text overflows and is hidden

Add ellipses after text overflows and is hidden

PHP中文网
PHP中文网Original
2017-06-21 09:02:391507browse

The effect of hiding and adding ellipses when we want the text to overflow

The width must be set in the current container or the parent container, otherwise the code will be invalid.

<span style="color: #800000">.box</span>{<span style="color: #ff0000">
         width</span>:<span style="color: #0000ff">50%</span>;<span style="color: #ff0000">
         text-overflow </span>:<span style="color: #0000ff">ellipsis</span>;<span style="color: #008000">/*</span><span style="color: #008000"> 文字隐藏后添加省略号 </span><span style="color: #008000">*/</span><span style="color: #ff0000">
         white-space </span>:<span style="color: #0000ff"> nowrap</span>;<span style="color: #008000">/*</span><span style="color: #008000"> 强制不换行 </span><span style="color: #008000">*/</span><span style="color: #ff0000">
         overflow </span>:<span style="color: #0000ff"> hidden</span>;<span style="color: #008000">/*</span><span style="color: #008000">自动隐藏文字</span><span style="color: #008000">*/</span><span style="color: #ff0000">
         width</span>:<span style="color: #0000ff"> 20em</span>;<span style="color: #008000">/*</span><span style="color: #008000">不允许出现半汉字截断</span><span style="color: #008000">*/</span>
    } 

The above is the detailed content of Add ellipses after text overflows and is hidden. 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