HTML - 文本和图像之间的不间断空格 [英] HTML - non-breaking space between text and image

查看:39
本文介绍了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&nbsp;<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.

这篇关于HTML - 文本和图像之间的不间断空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆