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

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

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

and

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

当前回答

在这三个类引导无效类

 .text-right {
     text-align: right; }

 .text-center {
     text-align: center; }

 .text-left {
    text-align: left; }

其他回答

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>

使用BootstrapX使用text-right完美工作:

<td class="text-right">
  text aligned
</td>

下面几行代码运行正常。你可以指定类,如文本中心,左或右,文本将相应地对齐。

<p class="text-center">Day 1</p> 
<p class="text-left">Day 2</p> 
<p class="text-right">Day 3</p>

这里不需要创建任何外部类。这些是Bootstrap类,它们有自己的属性。

这是最简单的解决办法

你可以像text-center, left或right这样分配类。文本将相应地对齐这些类。不必单独创建类。这些类是BootStrap 3中内置的

    <h1 class="text-center"> Heading 1 </h1> 
    <h1 class="text-left"> Heading 2 </h1> 
    <h1 class="text-right"> Heading 3 </h1>

检查: 演示

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中。这些类及其使用方式如有更改,恕不另行通知。