在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>
当前回答
v3.3.5中的引导文本对齐:
<p class="text-left">Left</p>
<p class="text-center">Center</p>
<p class="text-right">Right</p>
CodePen例子
其他回答
使用BootstrapX使用text-right完美工作:
<td class="text-right">
text aligned
</td>
Bootstrap 2.3具有文本左、文本右和文本中心实用程序类,但它们不能在表格单元格中工作。直到Bootstrap 3.0发布(他们已经修复了这个问题),我能够进行切换,我已经将此添加到我的网站CSS中,在Bootstrap . CSS之后加载:
.text-right {
text-align: right !important;
}
.text-center {
text-align: center !important;
}
.text-left {
text-align: left !important;
}
只需添加一个“自定义”样式表,它在Bootstrap的样式表之后加载。所以类定义是重载的。
在这个样式表中声明对齐方式如下:
.table .text-right {text-align: right}
.table .text-left {text-align: left}
.table .text-center {text-align: center}
现在你可以使用td和th元素的“通用”对齐约定了。
在Bootstrap版本4。有一些内置的类来定位文本。
对表头和数据文本进行居中:
<table>
<tr>
<th class="text-center">Text align center.</th>
</tr>
<tr>
<td class="text-center">Text align center.</td>
</tr>
</table>
您还可以使用这个类来定位任何文本。
<p class="text-left">Left aligned text on all viewport sizes.</p>
<p class="text-center">Center aligned text on all viewport sizes.</p>
<p class="text-right">Right aligned text on all viewport sizes.</p>
<p class="text-sm-left">Left aligned text on viewports sized SM (small) or wider.</p>
<p class="text-md-left">Left aligned text on viewports sized MD (medium) or wider.</p>
<p class="text-lg-left">Left aligned text on viewports sized LG (large) or wider.</p>
<p class="text-xl-left">Left aligned text on viewports sized XL (extra-large) or wider</p>
欲知详情
Bootstrap来了!在Bootstrap 3中熟悉的实用程序类。X现在是断点启用。默认的断点是:xs, sm, md, lg和xl,所以这些文本对齐类看起来像.text-[breakpoint]-[align]。
<div class="text-sm-left"></div> //or
<div class="text-md-center"></div> //or
<div class="text-xl-right"></div>
重要:在撰写本文时,Bootstrap 4只在Alpha 2中。这些类及其使用方式如有更改,恕不另行通知。