强迫物品保持在同一条线上

时间:2009-12-20 20:55:48

标签: html css line-breaks

这应该相当简单,但在google时我找不到任何有用的东西 我所拥有的是一些文字和一些图标,我想确保它们保持在同一条线上。例如,我想要这个:

Text goes here and eventually we run into the end of the line [text][icon]

或者这个:

Text goes here and eventually we run into the end of the line 
[text][icon]

但不是这样:

Text goes here and eventually we run into the end of the line [text]
[icon]

我在google-ing时唯一能够提出的是显然IE在实现这一点时遇到了一些问题。我真的不在乎IE是否能够做到(至少还没有),我只是想找到一个解决方案...... :)

3 个答案:

答案 0 :(得分:5)

将它放在一个容器中,为样式表中的whitespace属性指定了no-wrap。

答案 1 :(得分:1)

您需要使用不间断的空格,编码为 ,以防止间隔中断。

答案 2 :(得分:0)

考虑使用非中断空格 而不是最后一个单词和图标之间的空格。

例如:

Text goes here and eventually we run into the end of the line [text] [icon]

而不是

Text goes here and eventually we run into the end of the line [text] [icon]