Home > Web Front-end > HTML Tutorial > The text in css must be one line, and the problem of automatically hiding the exceeded part_html/css_WEB-ITnose

The text in css must be one line, and the problem of automatically hiding the exceeded part_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-24 11:50:15
Original
1280 people have browsed it

Problem: The customer requires that the text must be one line, and the excess part will be automatically hidden. But now there is no way to control the number of intercepted words in php, it can only be handled in the front-end css.

The width of the homepage div is certain.

The solution is:



  1. word-break: keep-all;/*This is optional */
    word-wrap: break-word;white-space: nowrap;<span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);">/*强制不换行,如果没有此行,则当用鼠标滑过的效果时,有可能会出现,因为超出的部分已经漂浮到其他的div上了*/</span>overflow: hidden;<span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);"> /*自动隐藏文字*/</span>
    Copy after login
    <span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);"><span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);">text-overflow: ellipsis;/*文字隐藏后添加省略号,如果不想用,可以省略此项*/ </span></span>
    Copy after login
    <span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);"><span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);"><span style="color: rgb(85, 85, 85); font-family: 微软雅黑, PMingLiU, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 22px; background-color: rgb(240, 240, 240);">width: 20em;/*不允许出现半汉字截断*/</span></span></span>
    Copy after login



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