Home > Web Front-end > HTML Tutorial > css换行的问题_html/css_WEB-ITnose

css换行的问题_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:24:25
Original
1337 people have browsed it

css html 换行 强制换行

<div style="width:400px;border:1px solid #333;word-wrap:break-word;">公交1346546546531343411324654324654132465465431346546541324651324654654132465435454354646546</div>
Copy after login

我想实现的是数字和文在在一行,现在到达容器边界时,文字和数字不在一行了。怎么办???
求大神指教!
谢谢!


回复讨论(解决方案)

<div style="width:400px;border:1px solid #333;word-break:break-all;">公交1346546546531343411324654324654132465465431346546541324651324654654132465435454354646546</div>
Copy after login

如果不用适用firefox的话,楼上的办法是可行的,如果要适用firefox的话,就得想别的办法了

<div style="width:400px;border:1px solid #333;word-wrap:break-word;display:inline;">公交1346546546531343411324654324654132465465431346546541324651324654654132465435454354646546</div>
Copy after login

回复一楼,试过了,可以的。谢谢。能说一下为什么吗?

回复一楼,试过了,可以的。谢谢。能说一下为什么吗?
word-break:break-all 这个css就是强制换行,无论任何情况下只要超过宽度,就会强制换行的,word-wrap:break-word 只是在一个完整单词的后面换行,就是就会识别 空格, 全角字去换行的,具体的可以上w3c看看,简单的解释,希望能帮到你

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