twitter-bootstrap Twitter bootstrap 水平居中对齐容器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26717285/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 21:48:04  来源:igfitidea点击:

Twitter bootstrap horizontal middle align container

csstwitter-bootstrap

提问by saimcan

I am having problem centering my container.

我在将容器居中时遇到问题。

<div class="row centered-form center-block">
    <div class="container col-md-10">
        <ul class="nav nav-tabs" id="projectTabs">
            <li role="presentation" class="active"><a href="#tab1" data-toggle="tab">Tab1</a></li>
            <li role="presentation"><a href="#Tab2" data-toggle="tab">Tab2</a></li>
        </ul>
    </div>
</div>

The main row is centered with approximately 65% width, but the container which contains navigation tabs sticks in this main row left.

主行以大约 65% 的宽度居中,但包含导航选项卡容器位于主行 left 中

Thank you in advance.

先感谢您。

回答by mikelt21

Use the col-md-offset-1class to move the container toward the center. Bootstrap uses a 12 column layout system so col-md-10makes your container10 columns wide but it starts on the left. Use offset to push the element over to the right by the indicated amount, so col-md-offset-1moves it 1 column to the right.

使用col-md-offset-1类将容器移向中心。Bootstrap 使用 12 列布局系统,因此col-md-10使您的container10 列宽,但它从左侧开始。使用 offset 将元素向右推指定量,因此col-md-offset-1将其向右移动 1 列。

<div class="row centered-form center-block">
    <div class="container col-md-10 col-md-offset-1">
        ...
    </div>
</div>