在Twitter的Bootstrap框架中是否有一组对齐文本的类?

例如,我有一些包含$ total的表格,我希望它们向右对齐……

<th class="align-right">Total</th>

and

<td class="align-right">$1,000,000.00</td>

当前回答

现在,随着Bootstrap 3的发布,你可以使用text-center类进行中心对齐,text-left类进行左对齐,text-right类进行右对齐,text-justify类进行对齐。

Bootstrap是一个非常简单的前端框架,一旦你使用它。以及非常容易定制,以满足您的喜好。

其他回答

Bootstrap 4有五个类:text left, text center, text right, text justify和text nowrap。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/> <div class="text-left">Left aligned text.</div> <div class="text-center">Center aligned text.</div> <div class="text-right">Right aligned text.</div> <div class="text-justify">Justified text starts here. The quick brown fox jumps over the lazy dog. Justified text ends here.</div> <div class="text-nowrap">No wrap text starts here. The quick brown fox jumps over the lazy dog. No wrap text ends here.</div>

使用text-align:center !重要。可能有其他的文本对齐css规则,所以!important是重要的。

表格 th, td { 颜色:黑色!重要; border-collapse:崩溃; 背景颜色:黄色! 边框:1px纯黑色; 填充:10 px; Text-align: center ! } <表> < tr > < th > 居中对齐文本 < / th > < / tr > < tr > <td>居中对齐文本</td> <td>居中对齐文本</td> < / tr > 表> < /

我猜是因为CSS已经有了text-align:right, AFAIK, Bootstrap没有一个专门的类。

Bootstrap确实有“右拉”浮动divs等到右边。

Bootstrap 2.3刚刚出来,增加了文本对齐样式:

Bootstrap 2.3发布(2013-02-07)

现在,随着Bootstrap 3的发布,你可以使用text-center类进行中心对齐,text-left类进行左对齐,text-right类进行右对齐,text-justify类进行对齐。

Bootstrap是一个非常简单的前端框架,一旦你使用它。以及非常容易定制,以满足您的喜好。

扩展David的回答,我只是添加了一个简单的类来增强Bootstrap,像这样:

.money, .number {
    text-align: right !important;
}