Bootstrap 5 Images
- Previous Page BS5 Table
- Next Page BS5 Jumbotron
Course Recommendations:
Image Shape
Rounded Corners
.rounded
Example
Class to add rounded corners to the image:
<img src="flower.jpg" class="rounded" alt="Flower">
Circle
.rounded-circle
Example
Class to shape the image into a circle:
<img src="flower.jpg" class="rounded-circle" alt="Cinque Terre">
Thumbnail
.img-thumbnail
Example
Class to shape the image into a thumbnail (with border):
<img src="flower.jpg" class="img-thumbnail" alt="Cinque Terre">
Align Images .float-start
Class to float the image to the left, or use .float-end
Float to the Right:
Example
<img src="tulip.jpg" class="float-start"> <img src="tulip.jpg" class="float-end">
Centered Image
To center the image, we added utility classes to the image .mx-auto
(margin:auto) and .d-block
(display:block):
Example
<img src="tulip.jpg" class="mx-auto d-block">
Responsive Images
Images come in various sizes. So does the screen. Responsive images will automatically adjust to fit the screen size.
By adding .img-fluid
Class Added to <img>
Tag to create responsive images. Then the image will scale well within the parent element.
.img-fluid
Class for Image Application max-width: 100%;
and height: auto;
:
Example
<img class="img-fluid" src="tiyugongyuan.jpg" alt="New York">
- Previous Page BS5 Table
- Next Page BS5 Jumbotron