在 bootstrap
div 浮动到右侧的正确方法是什么?我认为 pull-right
是推荐的方式,但它不起作用。
@import url('http://twitter.github.com/bootstrap/assets/css/bootstrap.css');
.container {
margin-top: 10px;
}
<div class="container">
<div class="row-fluid">
<div class="span6">
<p>Text left</p>
</div>
<div class="span6 pull-right">
<p>text right</p>
</div>
</div>
</div>
原文由 Justin 发布,翻译遵循 CC BY-SA 4.0 许可协议
您的行中有两个 span6 div,因此它们将占据一行的全部 12 个跨度。
将 pull-right 添加到第二个 span6 div 不会对其执行任何操作,因为它已经位于右侧。
如果你的意思是你想让第二个 span6 div 中的文本右对齐,那么简单地向那个 div 添加一个新类并给它 text-align: right 值例如
更新:
EricFreese 指出,在 Bootstrap 的 2.3 版(上周)中,他们添加了文本对齐实用程序类,您可以使用它们:
.text-left
.text-center
.text-right
http://twitter.github.com/bootstrap/base-css.html#typography