HTML - 文本和图像之间的不间断空格
问题描述:
所以我有一个菜单,其中每个(多行)项在菜单项的最后一个字之后都有一个图像 rightarrow.png.问题是有时这个箭头会自己进入换行符,我想阻止这种情况发生.我试过了
So I have a menu where each (multiline) item has an image rightarrow.png right after the last word of the menu item. The problem is sometimes this arrow goes into a newline by itself, and I want to stop that from happening. I tried
Blah blah <img src="rightarrow.png" />
但仍然在某些情况下看起来像
but still in some cases it looks like
Blah blah
>
这让我发疯.
答
将所有文本放在一个元素中,然后将图像放在另一个包装器中.将 white-space:nowrap
添加到它们的父级.
Put all your text in an element, then put the image in another wrapper. Add white-space:nowrap
to their parent.