If the original width of the responsive image is smaller than containing element it will not cover the full width, which looks ugly on small screens like tables and mobile phones.
You can solve this problem to some extent by center aligning the responsive image through applying an addition class .center-block on it, along with the .img-responsive class in Bootstrap 3.
The .center-block class is however removed in Bootstrap 4, but you can still achieve the same effect using the classes .d-block and .mx-auto along with the .img-responsive class.
The following example will work in both Bootstrap 3 and 4 versions.
Use the
center-block
ClassIf the original width of the responsive image is smaller than containing element it will not cover the full width, which looks ugly on small screens like tables and mobile phones.
You can solve this problem to some extent by center aligning the responsive image through applying an addition class
.center-block
on it, along with the.img-responsive
class in Bootstrap 3.The
.center-block
class is however removed in Bootstrap 4, but you can still achieve the same effect using the classes.d-block
and.mx-auto
along with the.img-responsive
class.The following example will work in both Bootstrap 3 and 4 versions.
need an explanation for this answer? contact us directly to get an explanation for this answer