【发布时间】:2010-08-24 07:49:08
【问题描述】:
如何在 html div 中显示长单词/url 时在某个点拆分它?
应该是这样的:
thisisareallylongwordt
hatneedstobebroken her
e or something like th
at.
【问题讨论】:
标签: css html line-breaks
如何在 html div 中显示长单词/url 时在某个点拆分它?
应该是这样的:
thisisareallylongwordt
hatneedstobebroken her
e or something like th
at.
【问题讨论】:
标签: css html line-breaks
如果您希望单词在 div 的边缘中断而不是溢出,请使用
div {word-wrap:break-word}
【讨论】:
需要手动插入<br>标签:
thisisareallylongwordt<br>
hatneedstobebroken her<br>
e or something like th<br>
at
没有像人们想要的那样多的 CSS 解决方案。
编辑: 正如 Raoul 建议的那样,软连字符 &shy; 也可以。我自己都不知道它的存在。
【讨论】:
您想要静态自动换行还是随着 div 大小的变化而更加动态?如果你想要后者,那么你可能想要使用 javascript。 jQuery 库有一个自动换行插件:
http://plugins.jquery.com/project/wordWrap
丹
【讨论】:
<textarea> 标签。