一个简单的用例场景是使用一个图像或 Bootstrap 列中的任何其他内容。通常这些内容需要水平居中。
<div class="container">
<div class="row">
<div class="col-sm-4 col-md-4 col-lg-4 text-center">
<img class="img-responsive" src="img/some-image.png" title="this image needs to be centered">
</div>
<div class="col-sm-8 col-md-8 col-lg-8">
some content not important at this moment
</div>
</div>
</div>
在版本3.1.0中添加类文本中心在列内的图像居中。但是为了解决其他一些问题,我不得不转到3.3.4版本,而这种行为(文本中心)现在已经被打破了。 留给我的问题是如何在一个列中居中显示图像或其他内容。 我希望避免向包含的元素添加类,因为这很容易出错,或者需要另一个包含 div 的元素。