我有这个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 。