<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section>
<div class="container">
<div class="row">
<div class="col-md-4">
<i class="fa fa-book fa-3x text-center" aria-hidden="true"></i>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
<div class="col-md-4">
<i class="fa fa-book fa-3x" aria-hidden="true"></i>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
<div class="col-md-4">
<i class="fa fa-book fa-3x" aria-hidden="true"></i>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
</div><!--end row-->
</div><!--end container-->
</section>
这是我的代码。我打算将字体真棒图标集中在各自列的中心,但我无法做到。
答案 0 :(得分:7)
text-center
移至列<div>
,然后此<div>
中的所有文字都会居中(我的示例中的第一行)。<div>
中添加额外的text-center
,并在其中移动您的图标(我的示例中的第二行)。
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section>
<div class="container">
<div class="row">
<div class="col-md-4 text-center">
<i class="fa fa-book fa-3x" aria-hidden="true"></i>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
<div class="col-md-4">
<div class="text-center">
<i class="fa fa-book fa-3x" aria-hidden="true"></i>
</div>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
</div><!--end row-->
</div><!--end container-->
</section>
答案 1 :(得分:0)
我认为这会奏效:
<div class="col-md-4" style="text-align:center;">
<i class="fa fa-book fa-3x text-center" aria-hidden="true"></i>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
答案 2 :(得分:0)
.center{
text-align:center;
width:50%;
}
HTML
<div class="center"><i class="fa fa-book fa-3x text-center" aria-hidden="true"></i></div>
这就像你想要的那样把它带到中间。
答案 3 :(得分:0)
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<section>
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="text-center"><i class="fa fa-book fa-3x" aria-hidden="true"></i></div>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
<div class="col-md-4">
<div class="text-center"><i class="fa fa-book fa-3x" aria-hidden="true"></i></div>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
<div class="col-md-4">
<div class="text-center"><i class="fa fa-book fa-3x" aria-hidden="true"></i></div>
<p>Ne mundi fabulas corrumpit vim, nulla vivendum conceptam</p>
</div>
</div><!--end row-->
</div><!--end container-->
</section>
&#13;
将字体真棒图标放入单独的div并应用&#34; text-center&#34;类。它会将字体很棒的图标对齐到中心。
答案 4 :(得分:0)
使用这种最简单的方法:
<div class="text-center"><i class="fa fa-book fa-3x text-center" aria-hidden="true"></i></div>