twitter-bootstrap Bootstrap 3 水平中心按钮组连续
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25529508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap 3 Horizontal Center Button Group In A Row
提问by Issa Fram
I am trying to horizontally center two radio buttons (in a group) on my page. This is what I have so far. It is not exactly center. It is a bit to the left. Pull right makes it go too far to the right. I added center-block and text-center but they did not help at all.
我试图在我的页面上水平居中两个单选按钮(在一个组中)。这就是我迄今为止所拥有的。它不完全是中心。它有点偏左。向右拉使它向右走得太远。我添加了 center-block 和 text-center 但它们根本没有帮助。
Can anyone help?
任何人都可以帮忙吗?
<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>
回答by Dan
You need to have text-centerin the parent div, not the div being centered.
您需要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>
Also, you should use col-sm-offset-5instead of <div class="col-sm-5"> </div>.
此外,您应该使用col-sm-offset-5代替<div class="col-sm-5"> </div>.

