Bootstrap 5 Image CSS Classes
1. Responsive Images
Make images scale nicely to the parent container with:
-
.img-fluid— appliesmax-width: 100%andheight: auto
2. Image Shapes
-
.rounded— Adds border-radius for rounded corners -
.rounded-circle— Makes the image circular (perfect for profile pics) -
.rounded-pill— Makes the image pill-shaped (rounded edges)
3. Image Thumbnails
Add a border and padding to create a thumbnail look:
-
.img-thumbnail
4. Aligning Images
Use .float-start or .float-end to float images left or right:
Add margin classes (me-3, ms-3) to create spacing around floated images.
5. Responsive Display Utilities
Control image visibility on different screen sizes with display utilities:
6. Figure Component
Bootstrap provides a nice wrapper .figure for images with captions:
Summary Table
| Class | Description |
|---|---|
.img-fluid |
Responsive image scaling |
.rounded |
Rounded corners |
.rounded-circle |
Circular image |
.rounded-pill |
Pill-shaped rounded image |
.img-thumbnail |
Bordered thumbnail style |
.float-start |
Float image left |
.float-end |
Float image right |
.figure |
Wrapper for images with caption |
