【发布时间】:2013-04-19 09:01:46
【问题描述】:
我有这个 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 here。
【问题讨论】:
-
你能改变 HTML 吗?还是你被它困住了?
-
是的,我可以修改 HTML..
标签: css