Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 强制项目保持在同一行_Html_Css_Line Breaks - Fatal编程技术网

Html 强制项目保持在同一行

Html 强制项目保持在同一行,html,css,line-breaks,Html,Css,Line Breaks,这应该相当简单,但我在谷歌搜索时找不到任何有用的东西。 我所拥有的是一些文本和一些图标,我想确保它们保持在同一行。例如,我想要这个: 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 an

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

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是否能够做到这一点(至少现在还没有),我只是想找到一个解决方案…:)

将其放在一个容器中,该容器没有为样式表中的whitespace属性指定换行符

将其放在一个容器中,该容器没有为样式表中的whitespace属性指定换行符

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

例如:

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]
而不是

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

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

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

我将此添加到代码中:(…)[文本][图标]发生的情况是,文本在div之外的每个空格上都换了一行。我是否犯了严重错误?使用span而不是div之类的内联元素。将其更改为span,但它仍然是一样的。您的容器太小,无法避免在一开始就破坏该行,或者您的样式表有问题。我将此添加到代码中:(…)[text][icon]发生的情况是,文本在div之外的每个空格上都换了一行。我是否犯了严重错误?使用span而不是div之类的内联元素。将其更改为span,但它仍然是一样的,你的容器太小,一开始就无法避免打断那一行,或者你的样式表有问题。问题是文本和图像之间没有空格,它仍然会中断。如果我加上一个问题,文本和图像之间没有空白,它仍然会断裂,这也是一个问题。如果我加上