零宽度单词连接器和 CSS 生成的内容
我想禁止网页中某些地方的换行(例如,当浏览器将文本“100 km/h”分成两行时,这真的很难看 - 在这个问题中,我担心“/”附近的换行) 。我尝试了这种方法,它有效实体
x‍/‍y <!-- x/y on one line -->
是一个零宽度单词连接器,类似于
,但没有空格。
然而,我担心一个稍微复杂的例子:
x‍/<span class="someclass"></span>
with style:
.someclass { content: "y"; }
这似乎在 Firefox 中有效(正常内容和生成内容之间没有换行符),但在 Opera 中,它失败了。这应该按照标准进行吗?
I want to disallow line breaks in some places in a web page (eg. it's really ugly when the browser breaks the text "100 km/h" on two lines - in this question I'm concerned about breaking near the "/"). I tried this approach and it works
x/y <!-- x/y on one line -->
The entity
is a zero-width word joiner, similar to
, but without space.
However, I am concerned about a slightly more complex example:
x/<span class="someclass"></span>
with style:
.someclass { content: "y"; }
This seems to work in Firefox (no linebreaks between normal and generated content), but in Opera, it fails. Should this work according to the standards?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置
white-space: nowrap;
如下所示:webdesignerwall.comSet
white-space: nowrap;
as seen here: webdesignerwall.com简单地设置 br 元素以显示 none 在 Chrome 上对我有用。 FF、IE之类的我不太清楚,不过应该不难查!
Simply setting the br element to display none worked for me on Chrome. I'm not sure about FF, IE, and the like, but it shouldn't be too hard to check!