Skip to main content Skip to docs navigation

Documentation and examples for opting images into responsive behavior (so they never become wider than their parent) and add lightweight styles to them—all via classes.

Responsive images

Images in Bootstrap are made responsive with .img-fluid. This applies max-width: 100%; and height: auto; to the image so that it scales with the parent width.

University of Arizona Spring Fling
html
<img class="img-fluid" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1.jpg" alt="University of Arizona Spring Fling">

Rounded corners

Custom Arizona Bootstrap Styling

Arizona Bootstrap rounds image corners by default using upstream Bootstrap’s border-radius() mixin. The default rounded corners are not applied to images with a card image class (.card-img, .card-img-top, or .card-img-bottom).

University of Arizona Spring Fling
html
<img class="img-fluid" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1.jpg" alt="University of Arizona Spring Fling">

Use .rounded-0 from the border radius utilities to override the default rounded corners and restore sharp corners on an image.

University of Arizona Spring Fling
html
<img class="img-fluid rounded-0" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1.jpg" alt="University of Arizona Spring Fling">

Image thumbnails

In addition to our border-radius utilities, you can use .img-thumbnail to give an image a rounded 1px border appearance.

University of Arizona Spring Fling
html
<img class="img-thumbnail" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1-thumb.jpg" alt="University of Arizona Spring Fling">

Aligning images

Align images with the helper float classes or text alignment classes. block-level images can be centered using the .mx-auto margin utility class.

University of Arizona Spring Fling University of Arizona Spring Fling
html
<img width="200" height="200" class="float-start" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1-thumb.jpg" alt="University of Arizona Spring Fling">
<img width="200" height="200" class="float-end" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1-thumb.jpg" alt="University of Arizona Spring Fling">
University of Arizona Spring Fling
html
<img width="200" height="200" class="mx-auto d-block" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1-thumb.jpg" alt="University of Arizona Spring Fling">
University of Arizona Spring Fling
html
<div class="text-center">
  <img width="200" height="200" src="/arizona-bootstrap/v5/docs/5.0/assets/img/photo-gallery-demo/gallery-img-1-thumb.jpg" alt="University of Arizona Spring Fling">
</div>

Picture

If you are using the <picture> element to specify multiple <source> elements for a specific <img>, make sure to add the .img-* classes to the <img> and not to the <picture> tag.

<picture>
  <source srcset="..." type="image/svg+xml">
  <img src="..." class="img-fluid img-thumbnail" alt="...">
</picture>

CSS

Sass variables

Variables are available for image thumbnails.

$thumbnail-padding:                 .25rem;
$thumbnail-bg:                      var(--#{$prefix}body-bg);
$thumbnail-border-width:            var(--#{$prefix}border-width);
$thumbnail-border-color:            var(--#{$prefix}border-color);
$thumbnail-border-radius:           var(--#{$prefix}border-radius);
$thumbnail-box-shadow:              var(--#{$prefix}box-shadow-sm);