2018 Update...
(2018年更新......)
Bootstrap 4.1+
(Bootstrap 4.1+)
-
pull-right
is now float-right
(pull-right
现在是float-right
)
-
text-right
is the same as 3.x, and works for inline elements (text-right
与3.x相同,适用于内联元素)
- both
float-*
and text-*
are responsive for different alignment at different widths (ie: float-sm-right
) (float-*
和text-*
都响应不同宽度的不同对齐(即: float-sm-right
))
The flexbox utils (eg: justify-content-between
) can also be used for alignment:
(flexbox utils(例如: justify-content-between
)也可用于对齐:)
<div class="d-flex justify-content-between">
<div>
left
</div>
<div>
right
</div>
</div>
or, auto-margins (eg: ml-auto
) in any flexbox container (row,navbar,card,d-flex,etc...)
(或者,任何弹性箱容器中的自动边距(例如: ml-auto
)(行,导航栏,卡片,d-flex等...))
<div class="d-flex">
<div>
left
</div>
<div class="ml-auto">
right
</div>
</div>
Bootstrap 4 Align Demo
(Bootstrap 4对齐演示)
Bootstrap 4 Right Align Examples (float, flexbox, text-right, etc...)
(Bootstrap 4右对齐示例 (float,flexbox,text-right等...))
Bootstrap 3
(Bootstrap 3)
Use the pull-right
class..
(使用pull-right
类..)
<div class="container">
<div class="row">
<div class="col-md-6">Total cost</div>
<div class="col-md-6"><span class="pull-right">$42</span></div>
</div>
</div>
Bootstrap 3 Demo
(Bootstrap 3演示)
You can also use the text-right
class like this:
(你也可以使用像这样的text-right
类:)
<div class="row">
<div class="col-md-6">Total cost</div>
<div class="col-md-6 text-right">$42</div>
</div>
Bootstrap 3 Demo 2
(Bootstrap 3演示2)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…