我有一些这样的html:
<ul>
<li>
<small class="text-muted text-small" style="display:inline-block" >Hello</small>
<span style="display:inline-block"> World</span>
<small class="text-muted text-small" style="display:inline-block" >Hello second time</small>
<span style="display:inline-block"> World</span>
</li>
</ul>
它看起来像:
你好,世界
你好第二次世界
但是我想将小标签和跨度标签排列到列中,所以它看起来像这样:
你好,世界
你好第二次世界
我正在使用bootstrap进行样式设置,并尝试分配小标签col-md类进行操作,但是它并没有按照我的意愿对齐。
有什么建议么 ?
最佳答案
您应该可以使用以下样式实现此目的:
li {display:inline-block;}
span {float:right; margin-left:1em;}
/*the margin can be however large you want the gap between the words*/
Example
抱歉,仅在chrome中进行了测试,但无法正常工作,对于chrome,您需要添加
small {float:left; clear:both;}
Example