在Twitter的Bootstrap框架中是否有一组对齐文本的类?
例如,我有一些包含$ total的表格,我希望它们向右对齐……
<th class="align-right">Total</th>
and
<td class="align-right">$1,000,000.00</td>
在Twitter的Bootstrap框架中是否有一组对齐文本的类?
例如,我有一些包含$ total的表格,我希望它们向右对齐……
<th class="align-right">Total</th>
and
<td class="align-right">$1,000,000.00</td>
当前回答
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>
其他回答
我猜是因为CSS已经有了text-align:right, AFAIK, Bootstrap没有一个专门的类。
Bootstrap确实有“右拉”浮动divs等到右边。
Bootstrap 2.3刚刚出来,增加了文本对齐样式:
Bootstrap 2.3发布(2013-02-07)
v3.3.5中的引导文本对齐:
<p class="text-left">Left</p>
<p class="text-center">Center</p>
<p class="text-right">Right</p>
CodePen例子
下面几行代码运行正常。你可以指定类,如文本中心,左或右,文本将相应地对齐。
<p class="text-center">Day 1</p>
<p class="text-left">Day 2</p>
<p class="text-right">Day 3</p>
这里不需要创建任何外部类。这些是Bootstrap类,它们有自己的属性。
.text-align类完全有效,比.price-label和.price-value更有用,后者已经没有任何用处了。
我建议100%使用自定义实用程序类
.text-right {
text-align: right;
}
我喜欢施魔法,但那取决于你,比如
span.pull-right {
float: none;
text-align: right;
}
只需添加一个“自定义”样式表,它在Bootstrap的样式表之后加载。所以类定义是重载的。
在这个样式表中声明对齐方式如下:
.table .text-right {text-align: right}
.table .text-left {text-align: left}
.table .text-center {text-align: center}
现在你可以使用td和th元素的“通用”对齐约定了。