html - Bootstrap - 如何将其中有文本的 div 居中?

标签 html css twitter-bootstrap

我希望能够将包含以下文本的 div 置于页面中间。我虽然可以在 Bootstrap 中使用“center-block”类,但它似乎不起作用:

实时预览: http://codepen.io/anon/pen/tCIlG

Code below:

 <div class="row">
      <div class="col-md-4 center-block text-center">

        I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.

      </div>
    </div>

最佳答案

.col-md-4 类导致它向左浮动而不是居中。如果你想保持那个类的宽度,你可以在 CSS 中覆盖它:

.col-md-4.center-block {
    float: none;
}

更新代码笔:http://codepen.io/sdsanders/pen/lHrvu

关于html - Bootstrap - 如何将其中有文本的 div 居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26664498/

相关文章:

twitter-bootstrap - xpage 模态对话框和 sessionScopes

javascript - HTML Javascript 富文本框 (IDE)

javascript - 从复选框中选择选中的值

css - <div> 元素在移动设备上相互堆叠

javascript - 背景淡入淡出,将焦点留在弹出窗体/元素上

javascript - Bootstrap 导航栏事件状态不工作

java - 在 @PostConstruct 中调用 JSNI 方法 - Errai

javascript - 使用 jquery 制作 3d 效果

html - 在 Bootstrap 上将标题拆分为 2 列(每边 50%)

html - 无法让菜单栏在 IE 中工作