我有这样的 HTML:
<ul>
<li class="completed"><a href="#">I want the icon to stay on the same line as this last <strong>word</strong></li>
</ul>
我使用: after 伪元素添加一个图标:
ul li.completed a:after {
background:transparent url(img.png) no-repeat;
content: '';
display:inline-block;
width: 24px;
height: 16px;
}
问题是: 如果可用的宽度太小,图标会换到下一行。我希望它与链接的最后一个单词保持在同一行上:
这是可行的,不添加“ nowrap”到整个链接(我希望文字包装,只是不要图标)。
参见 jsFiddle 给你。