“硬” html / css 中的断字/分割

发布于 2024-09-15 17:07:01 字数 158 浏览 8 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

┾廆蒐ゝ 2024-09-22 17:07:01

如果您希望单词在 div 的边缘处断开而不是溢出,请使用

div {word-wrap:break-word}

if you are wanting the word to break at the edge of the div rather than to overflow it use

div {word-wrap:break-word}
昵称有卵用 2024-09-22 17:07:01

您需要手动插入
标签:

thisisareallylongwordt<br>
hatneedstobebroken her<br>
e or something like  th<br>
at

据我所知,没有一种 CSS 解决方案能够满足人们的需求。

编辑: 正如 Raoul 建议的那样,软连字符 ­ 也有效。我自己并不知道存在。

You need to manually insert <br> tags:

thisisareallylongwordt<br>
hatneedstobebroken her<br>
e or something like  th<br>
at

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.

水晶透心 2024-09-22 17:07:01

您想要静态自动换行还是随着 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文