Home >Web Front-end >HTML Tutorial >css 长文本及长链接自动换行的几种方法

css 长文本及长链接自动换行的几种方法

WBOY
WBOYOriginal
2016-06-01 09:53:172185browse

方法一:你定死表格的宽度,即给表格一个宽度值(是数值,不是百分比) 

 

方法二:强制不换行

div{//white-space:不换行;normal 默认;nowrap强制在同一行内显示所有文本,直到文本结束或者遭遇 br 对象white-space:nowrap; }

 

方法三:自动换行

div{ word-wrap: break-word;

//word-break设置强行换行;normal 亚洲语言和非亚洲语言的文本规则,允许在字内换行word-break: normal; }

 

方法四:强制英文单词断行

div{word-break:break-all;}

 

另外,只要在CSS中定义了如下句子,可保网页不会再被撑开了。

table{table-layout: fixed;}td(word-break: break-all; word-wrap:break-word;)

 

既防止表格/层撑破又防止单词断裂

table { table-layout: fixed;word-wrap:break-word;}div { word-wrap:break-word;}

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