我希望能够将包含以下文本的 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;
}
关于html - Bootstrap - 如何将其中有文本的 div 居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26664498/