如果具有 .img-responsive
类的图像宽度小于容器宽度,则它显示为左对齐。将 .text-center
添加到父元素似乎不起作用。这是一个例子:
<div class="col-sm-12 text-center">
<img src="path/to/image.jpg" alt="Example Image" class="img-responsive" />
</div>
最佳答案
如果您真的想遵循 Twitter Bootstrap 语法,您应该使用 center-block
类,如文档中所述。
代码种类:
<img class="center-block" src="something.xxx" alt="xxx">
关于css - 在 Bootstrap 中水平居中响应图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30103364/