“硬” html / css 中的断字/分割
在 html div 中显示长单词/url 时,如何在某个点拆分它?
它应该是这样的:
thisisareallylongwordt
hatneedstobebroken her
e or something like th
at.
How can I split a long word/url at a certain point when displaying it in a html div?
It should be like:
thisisareallylongwordt
hatneedstobebroken her
e or something like th
at.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您希望单词在 div 的边缘处断开而不是溢出,请使用
if you are wanting the word to break at the edge of the div rather than to overflow it use
您需要手动插入
标签:据我所知,没有一种 CSS 解决方案能够满足人们的需求。
编辑: 正如 Raoul 建议的那样,软连字符
也有效。我自己并不知道存在。You need to manually insert
<br>
tags:There is afaik no CSS solution as much as one would want one.
Edit: As Raoul suggested the soft-hyphen
works too. Did not know that existed myself.您想要静态自动换行还是随着 div 大小的变化而变得更加动态?如果你想要后者那么你可能想要使用 javascript。 jQuery 库有一个自动换行插件:
http://plugins.jquery.com/project/wordWrap< /a>
丹
Do you want a static word wrap or something more dynamic as the size of the div changes? If you want the latter then you will probably want to use javascript. The jQuery library has a word-wrap plugin:
http://plugins.jquery.com/project/wordWrap
Dan