I'm attempting to center an element within a Bootstrap column that comprises a fixed-width image (which is narrower than the column width) and some text below the image that aligns with the left edge of the image (and not with the left edge of the Bootstrap column).
Here's an example of my code:
.imgWidth {
max-width:150px;
}
<div class="row text-center">
<div class="col-xs-12 col-sm-12 col-md-2 text-center">
</div>
<div class="col-xs-12 col-sm-6 col-md-2">
<div class="text-center"><img class="imgWidth" src="/assets/img/photo.jpg"></div>
<div class="text-left">text under image</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-2">
<div class="text-center"><img class="imgWidth" src="/assets/img/photo.jpg"></div>
<div class="text-left">text under image</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-2">
<div class="text-center"><img class="imgWidth" src="/assets/img/photo.jpg"></div>
<div class="text-left">text under image</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-2">
<div class="text-center"><img class="imgWidth" src="/assets/img/photo.jpg"></div>
<div class="text-left">text under image</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-2 text-center">
</div>
</div>
This implementation centers the image in the column, but the text ends up aligned with the column instead of directly beneath the image. Is there a way to ensure that text is properly aligned with the image above it? I've attempted various code combinations without any success.