css - Bootstrap 中的中心侧边栏内容

标签 css twitter-bootstrap

我需要将侧边栏居中。这是我的布局(不起作用):

<body>
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span9">
        ...
      </div>
    <div class="span3">
    //sidebar
      <div class="row-fluid">
        <div class="span12 center-block">
          //content which should be centered
        </div>
      </div>
    </div>
  </div>
</body>

中心 block 代码我拿了here :

.center-block {
 margin:0 auto;
 float:none;
}

最佳答案

.center-block {
    margin:0 auto;
    float:none;
}

通过使用上面的代码,它会将 center-block 居中Div 不是其中的内容,要对齐您需要添加的内容 text-align:center.center-block像这样上课:

.center-block {
    margin:0 auto; /*It will center the block*/
    float:none;
    text-align:center; /*It will center the content inside block*/
}

关于css - Bootstrap 中的中心侧边栏内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11342013/

相关文章:

python - django 无法读取静态文件夹中的 css 文件

html - 使用 Bootstrap 的全 Angular 标签(支持 IE)

javascript - 单击列表中的 Bootstrap 输入按钮会禁用其他按钮

css - Bootstrap - 仅在 Internet Explorer 上控制由点包裹的焦点

asp.net-mvc - MVC Bootstrap TextBoxFor EditorFor

html - 处理滚动菜单 (css) - 我的菜单运行良好,直到我想区分当前页面

html - Flexbox - 最后一个元素放置在 "floating"右边

php - 为什么我的子主题不使用新的 style.css 文件?

twitter-bootstrap - Flexbox div 不在另一个 div 内居中

html - 无法将图像放入适当的容器中。图像堆叠,div 乱序?