2009-12-20 52 views
1

这应该相当简单,但在谷歌搜索时我还找不到任何有用的东西。
我所拥有的是一些文字和一些图标,我想确保它们保持在同一条线上。例如,我想这一点:强制项目保留在同一行

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] 

我已经能够拿出谷歌,荷兰国际集团与时唯一这显然是IE浏览器在执行此操作时遇到的一些问题我真的不在乎IE是否能够做到(至少现在还没有),我只想找到一个解决方案... :)

回答

4

把它放在一个容器中,样式表中的空白属性。

+0

我将此代码添加到了代码中: (...)

[text][icon]
发生了什么事情是文本在div外的每个空白处都突破了新行。我在做可怕的错误吗? – Paul 2009-12-20 21:10:42

+0

使用内联元素,如跨度而不是div。 – 2009-12-20 21:19:51

+0

将其更改为跨度,但仍相同 – Paul 2009-12-20 21:25:05

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] 
+0

问题是文本和图像之间没有空白,并且它仍然中断。如果我添加 ,也是如此 – Paul 2009-12-20 21:13:45

1

您需要使用非中断空格,编码 防止之间的空间休息。