Bootstrap 3水平中心按钮组连续

Iss*_*ram 3 html css html5 twitter-bootstrap twitter-bootstrap-3

我试图在我的页面上水平居中两个单选按钮(在一组中).这就是我到目前为止所拥有的.它不完全是中心.它有点左边.向右拉使其向右移动太远.我添加了中心区和文本中心,但他们根本没有帮助.

有人可以帮忙吗?

<div class="row">
    <div class="col-sm-5">&nbsp;</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">&nbsp;</div>
</div>
Run Code Online (Sandbox Code Playgroud)

Dan*_*Dan 10

您需要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>
Run Code Online (Sandbox Code Playgroud)

此外,你应该使用col-sm-offset-5而不是<div class="col-sm-5">&nbsp;</div>.

Bootply演示