HTML 非中断 space 无法正常工作

HTML non-breaking space is not working properly

在我看来,不间断 space 的 HTML 实体在我的代码中无法正常工作。我使用: zvyšováním ceny – ta by negativně 但不是连接在一起的破折号和两个词,我在新行的开头看到一个丑陋的白色 space 。你知道如何解决这个问题吗?

I know about about a non-breaking hyphen, but please remember there is the difference between a hyphen and a dash.

不间断的 space 不会阻止连字符成为单词可以断开的点,因此它有效地在连字符前后强制使用 space。

改用a non-breaking hyphen

zvyšováním ceny‑ta by negativně

我想你想要的是U+2060 WORD JOINER。这是为了在不引入任何间距的情况下抑制可能发生的换行。

这是它应有的工作方式,当有破折号或连字符时,一行会中断,但在使用 none 中断连字符时不会,因此添加   只会阻止在 space 处换行,因此称为 no breaking space ..

.. 因此它会在破折号处中断,下面的   导致下一行开头的丑陋的白色 space

通过删除 2:nd  ,像这样,它会工作正常并且在下一行开始 space

Some text having hyp - pen that should break after the hyphen
and another with the da – sh that should break after the dash

Fiddle demo

如果您不希望它损坏,骗子 link 有所需的答案,可以使用不间断的连字符或将其包装并将包装器设置为 white-space: nowrap

欺骗link:No line-break after a hyphen