Bootstrap offers different classes for images to make their appearance better and also to make them responsive. Making an image responsive means that it should scale according to its parent element. That is, the size of the image should not overflow it’s parent and will grow and shrink according to the change in the size of its parent without losing its aspect ratio.
The different classes available in Bootstrap for images are as explained below:
- .img-responsive class: Responsive images in Bootstrap are created by adding .img-responsive class to img tag. An img-responsive class applies: max-width: 100% | height:auto | display:block onto the image.
<!DOCTYPE html><html><head><!-- Link Bootstrap CSS --><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><!-- Link Bootstrap JS and JQuery --></head><body><divclass="container"><h1>Responsive Image </h1><br><h3>.img-responsive class</h3><p>Change the size of the browser windowto see effect</p>class="img-responsive"alt="Responsive image"width="307"height="240"/></div></body></html>chevron_rightfilter_noneOutput:
- .img-fluid class: Add .img-fluid class to
tag. The .img-fluid class applies : max-width: 100% | height: auto onto the image.
<!DOCTYPE html><html><head><!-- Link Bootstrap CSS --><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><!-- Link Bootstrap JS and JQuery --></head><body><divclass="container"><h3>.img-fluid class</h3><p>Change the size of the browser windowto see effect.</p>class="img-fluid"alt="Responsive Image"width="307"height="240"/></div></body></html>chevron_rightfilter_noneOutput:
- .img-rounded class: The rounded corners to an image arw added by .img-rounded class. (Rounded corners are not supported by IE8.)
<!DOCTYPE html><html><head><!-- Link Bootstrap CSS --><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><!-- Link Bootstrap JS and JQuery --></head><body><divclass="container"><h3>.img-rounded class</h3><p>Rounded Corners</p>class="img-rounded"alt="Responsive Image"width="307"height="240"/></div></body></html>chevron_rightfilter_noneOutput:
- .img-circle class: The shape of image is made circle by .img-circle class.(Rounded corners are not supported by IE8.)
<!DOCTYPE html><html><head><!-- Link Bootstrap CSS --><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><!-- Link Bootstrap JS and JQuery --></head><body><divclass="container"><h3>.img-circle class </h3><p>Circle</p>class="img-circle"alt="Responsive Image"width="307"height="240"/></div></body></html>chevron_rightfilter_noneOutput:
- .img-thumbnail class: Shaping of image to a thumbnail is done by the .img-thumbnail class.
<!DOCTYPE html><html><head><!-- Link Bootstrap CSS --><linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"><!-- Link Bootstrap JS and JQuery --></head><body><divclass="container"><h3>.img-thumbnail class</h3><p>Thumbnail</p>class="img-thumbnail"alt="Responsive Image"width="307"height="240"></body></html>chevron_rightfilter_noneOutput:
Recommended Posts:
- Responsive Video or Slideshow Embeds in Bootstrap with Examples
- Bootstrap (Part-5) | DropDowns and Responsive Tabs
- How to create Responsive Bottom Navigation Bar using Bootstrap ?
- How to create responsive image gallery using HTML, CSS, jQuery and Bootstrap?
- How to create responsive website zoomed out to full width on mobile using Bootstrap?
- How to design Responsive card-deck with fixed width in Bootstrap ?
- How to make the existing bootstrap 2 table responsive?
- Creating Responsive Grid Vanilla using HTML,CSS and Bootstrap
- Bootstrap 4 | Images
- How to display multiple horizontal images in Bootstrap card ?
- How to Display Validation Message for Radio Buttons with Inline Images using Bootstrap 4 ?
- Why card images use data-src (not src) for image in Bootstrap 4 ?
- How to use grid for images in bootstrap card ?
- How to put images in a box without space using Bootstrap?
- How to create a responsive Modal Sign-Up form for a Website?
- HTML | Responsive Modal Login Form
- HTML | Responsive full page image using CSS
- HTML | Viewport meta tag for Responsive Web Design
- Best way to make a d3.js visualization layout responsive
- How to hide elements in responsive layout using CSS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

