html - 对面

标签 html css

这个问题在这里已经有了答案:





How to stop text from taking up more than 1 line?

(5 个回答)


3个月前关闭。




有没有办法到不是 在特定点打断一个词?
类似于 &shy 的反面?
我已将文本设置为 hyphens: auto;但在某个特定点,这个词会中断,这是不正确的。我已经设置了 &shy在单词的多个位置,但它仍然在错误的位置中断。
我想在 html 中插入一些东西(没有 css 或任何东西,因为它必须工作编辑),告诉浏览器在这一点上无论如何都不要中断。

最佳答案

AFAIK 没有明确的 HTML 特殊字符来执行此操作。
一种解决方法可能是指定您的整个内容在任何地方都可破解,并将单词中不可破解的部分包装在 span 中。没有断词。
然后,您可以在编辑器中决定希望该词停止的位置:

.breakable {
  word-break: break-all;
}
.unbreakable {
  word-break: normal;
  color: red;
}
<div class="breakable">Browser can break anywhere here, but not where I decide: on this <span class="unbreakable">specificsuperlong</span>wordofmine, the red part is unbreakable. </div>
<div class="breakable">If I want to decide a special position it can only split on, I wrap my special <span class="unbreakable">unbrea</span>k<span class="unbreakable">able</span> in two spans.</div>

关于html - 对面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68271266/

相关文章:

html - 使用 CSS 添加状态图标

html - 与 div 元素相比,图像变得不对齐,尽管有相同的 css

html - 什么 CSS 规则导致我的绝对定位元素被隐藏

css - 突出显示表中的字段并打印

html - 在使用html表单上传的Django中读取Excel文件

html - 哈希键 "#"从 html 页面上的 "tel:"链接中的 ussd 代码中剥离

javascript - 新选项卡始终打开,甚至正常表单提交

html - 单行不隐藏滚动条?

php - 将用户输入的值从 php 表单更新到数据库

javascript - 如何在div标签上添加斑马条纹背景