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.
Available in Other JavaScript Frameworks
CoreUI Bootstrap 6 Images is also available for Angular, React, and Vue. Explore framework-specific implementations below:
Responsive images
Images in CoreUI for 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 element. To pair an image with a caption, see Figures.
<img src="..." class="-lg img-fluid" alt="...">Image thumbnails
In addition to our border-radius utilities, you can use .img-thumbnail to give an image a rounded 1px border appearance.
<img src="..." class="img-thumbnail" alt="...">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.
<img src="..." class="rounded float-start" alt="...">
<img src="..." class="rounded float-end" alt="..."><img src="..." class="rounded mx-auto d-block" alt="..."><div class="text-center">
<img src="..." class="rounded" alt="...">
</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.
Give the <img /> an alt text that describes the image, or an empty alt="" when it’s only decorative. The alt="..." in the example below is a placeholder for that text.
<picture>
<source srcset="..." type="image/svg+xml">
<img src="..." class="img-fluid img-thumbnail" alt="...">
</picture>Customizing
CSS variables
.img-thumbnail declares its frame on the element, so a single thumbnail can be reframed without a modifier class:
$thumbnail-tokens: defaults(
(
--cui-thumbnail-padding-y: .25rem,
--cui-thumbnail-padding-x: .25rem,
--cui-thumbnail-bg: var(--cui-bg-body),
--cui-thumbnail-border-width: var(--cui-border-width),
--cui-thumbnail-border-color: var(--cui-border-color),
--cui-thumbnail-border-radius: var(--cui-radius-5),
--cui-thumbnail-box-shadow: var(--cui-box-shadow-sm),
),
$thumbnail-tokens
);<img src="..." class="img-thumbnail" style="--cui-thumbnail-padding-y: .5rem; --cui-thumbnail-padding-x: .5rem; --cui-thumbnail-border-color: var(--cui-primary-base);" alt="...">