Bootstrap Images
In this chapter, we will learn about Bootstrap's support for images. Bootstrap provides three classes that apply simple styles to images:
- .img-rounded: Add the border-radius:6px to give an image rounded corners.
- .img-circle: Add the border-radius:50% to make the whole image circular.
- .img-thumbnail: add some padding and a gray border.
See the following example:
Example
<img src="/wp-content/uploads/2014/06/download.png" class="img-rounded">
<img src="/wp-content/uploads/2014/06/download.png" class="img-circle">
<img src="/wp-content/uploads/2014/06/download.png" class="img-thumbnail">Try it »
The result is as follows:
class
The following classes can be used with any image.
| class | Description | Example |
|---|---|---|
| .img-rounded | Add rounded corners to an image (not supported in IE8) | Try it |
| .img-circle | Make an image circular (not supported in IE8) | Try it |
| .img-thumbnail | Thumbnail | Try it |
| .img-responsive | Responsive image (will scale nicely to the parent element) | Try it |
Responsive Images
By adding the .img-responsive class to the tag, you make the image responsive. The image will scale nicely to its parent element.
The .img-responsive class applies max-width: 100%; and height: auto; styles to the image:
Example
<
img
src=
"cinqueterre.jpg"
class=
"img-responsive"
alt="Cinque Terre"
Try it »