您如何使用 Twitter Bootstrap 获得居中的内容? [英] How do you get centered content using Twitter Bootstrap?
问题描述
我正在尝试遵循一个非常基本的示例.使用 起始页和网格系统,我希望如下:
<div class="span12"><h1>Bootstrap 启动模板</h1><p>示例文本.</p>
...会产生居中文本.
然而,它仍然出现在最左边.我做错了什么?
This is for Text Centering(问题是关于什么)
对于其他类型的内容,请参阅Flavien 的回答.
更新:Bootstrap 2.3.0+ 答案
最初的答案是针对早期版本的引导程序.从 bootstrap 2.3.0 开始,你可以简单地给 div 类.text-center
.
原始答案(2.3.0 之前)
您需要使用 text-align: center
定义两个类之一,row
或 span12
.请参阅 http://jsfiddle.net/xKSUH/ 或 http://jsfiddle.net/xKSUH/1/
I'm trying to follow a very basic example. Using the starter page and the grid system, I was hoping the following:
<div class="row">
<div class="span12">
<h1>Bootstrap starter template</h1>
<p>Example text.</p>
</div>
</div>
...would produce centered text.
However, it still appears on the far left. What am I doing wrong?
This is for Text Centering (which is what the question was about)
For other types of content, see Flavien's answer.
Update: Bootstrap 2.3.0+ Answer
The original answer was for an early version of bootstrap. As of bootstrap 2.3.0, you can simply give the div the class .text-center
.
Original Answer (pre 2.3.0)
You need to define one of the two classes, row
or span12
with a text-align: center
. See http://jsfiddle.net/xKSUH/ or http://jsfiddle.net/xKSUH/1/
这篇关于您如何使用 Twitter Bootstrap 获得居中的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!