我试图在我的页面上水平居中放置两个单选按钮(在一组中)。这是我到目前为止所拥有的。它不完全是中心。它有点偏左。向右拉会使它向右走得太远。我添加了 center-block 和 text-center 但它们根本没有帮助。
有人能帮忙吗?
<div class="row">
<div class="col-sm-5"> </div>
<div class="col-sm-2">
<div class="btn-group center-block text-center" data-toggle="buttons">
<label class="btn btn-default center-block"><input type="radio">All</label>
<label class="btn btn-default active center-block"><input type="radio">Filtered</label>
</div>
</div>
<div class="col-sm-5"> </div>
</div>
最佳答案
你需要有 text-center
在父 div 中,而不是居中的 div。
<div class="row">
<div class="col-sm-offset-5 col-sm-2 text-center">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default center-block"><input type="radio">All</label>
<label class="btn btn-default active center-block"><input type="radio">Filtered</label>
</div>
</div>
</div>
此外,您应该使用 col-sm-offset-5
而不是 <div class="col-sm-5"> </div>
.
Bootply Demo
关于css - Bootstrap 3 水平中心按钮组连续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25529508/