Reputation: 623
I want to center my images inside the Bootstrap grid like this - https://i.sstatic.net/xJiiS.jpg; the image should be centered in the blue box (both on desktop and mobile).
here's my 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>
Upvotes: 0
Views: 4329
Reputation: 362270
Just use the Bootstrap 3 center-block
class in your images...
I also simplfied your markup to remove unnecessary nesting..
<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>
Upvotes: 7
Reputation: 551
should be just a matter of css
.image a {
display: block;
}
.image a img {
margin 0 auto;
display: block;
}
Upvotes: 1
Reputation: 380
This will do the trick ;)
.image.img-responsive {
text-align: center;
}
Upvotes: 0