我想将我的图像集中在Bootstrap网格中,如下所示 - http://i.imgur.com/weTvp5Q.jpg;图像应位于蓝色框中(桌面和移动设备上)。
这是我的HTML:
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<div class="image img-responsive">
<a href="#"><img class="img-responsive " src="http://i.imgur.com/GFZbJZr.jpg" border="0"></a>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<div class="image img-responsive">
<a href="#"><img class="img-responsive " src="http://i.imgur.com/pJF2nvM.jpg" border="0"></a>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<div class="image img-responsive">
<a href="#"><img class="img-responsive " src="http://i.imgur.com/JYYrpgD.jpg" border="0"></a>
</div>
</div>
</div>
答案 0 :(得分:7)
只需在图片中使用Bootstrap 3 center-block
课程即可...
我还简化了你的标记以删除不必要的嵌套..
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<a href="#"><img class="img-responsive center-block" src="http://i.imgur.com/GFZbJZr.jpg" border="0"></a>
</div>
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<a href="#"><img class="img-responsive center-block" src="http://i.imgur.com/pJF2nvM.jpg" border="0"></a>
</div>
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<a href="#"><img class="img-responsive center-block" src="http://i.imgur.com/JYYrpgD.jpg" border="0"></a>
</div>
</div>
答案 1 :(得分:1)
应该只是css的问题
.image a {
display: block;
}
.image a img {
margin 0 auto;
display: block;
}
答案 2 :(得分:0)
试试这个。
img {
margin:0 auto;
width:50%
}
答案 3 :(得分:0)
这样可以解决问题;)
.image.img-responsive {
text-align: center;
}
答案 4 :(得分:0)
尝试添加你的css:
div.image {
text-align: center;
}