BBS5 Images

Learn about Bootstrap 5 image classes.

BS5 Images

Bootstrap 5 provides classes to style images.

Image Shapes

  • .rounded adds rounded corners to an image
  • .rounded-circle shapes the image to a circle
  • .img-thumbnail shapes the image to a thumbnail (border)

Aligning Images

Float an image to the right with the .float-end class or to the left with .float-start.

Center an image by adding the utility classes .mx-auto (margin: auto) and .d-block (display: block) to the image.

Responsive Images

Images come in all sizes. So do screens. Responsive images automatically adjust to fit the size of the screen.

Create responsive images by adding an .img-fluid class to the <img> tag. The image will then scale nicer to the parent element.

Examples

Rounded Image

html/css

Adds rounded corners.

<img src="cinqueterre.jpg" class="rounded" alt="Cinque Terre">

Circle Image

html/css

Shapes image into a circle.

<img src="cinqueterre.jpg" class="rounded-circle" alt="Cinque Terre">

Thumbnail Image

html/css

Adds a border and padding.

<img src="cinqueterre.jpg" class="img-thumbnail" alt="Cinque Terre">

Responsive Image

html/css

Image scales with parent width.

<img src="img_girl.jpg" class="img-fluid" alt="Girl in a jacket">

Test Your Knowledge

1. Which class makes an image responsive?

2. Which class shapes an image into a circle?