I have started an article series on Bootstrap and published five articles so far. Read the previous five parts here.
Introduction
In this article we will learn about Bootstrap Images, style and shapes of images, by which we can create an interactive and responsive image gallery for web pages.
Bootstrap Image Shapes
By using the Bootstrap classes we can easily style images like making images round, cornered, or circular images, or we can give thumbnail effect on images. We have the following classes for image shapes.
- Rounded Corners:The .img-rounded class used for adding rounded corners to an image.
- Circle: The .img-circle class used for shaping the image to a circle.
- Thumbnail: The .img-thumbnail class used for shaping the image to a thumbnail.
Example 1 : Bootstrap Image Shapes
In this example we will give different shapes of images using the above Bootstrap classes, we will put an image inside images folder where our html page exists. After that, we will give shapes on image: Rounded, Circle,or Thumbnail by using the following code.
Output: Bootstrap Image Shapes
Responsive Images
Responsive images automatically adjust to fit the size of the screen. In Bootstrap we can create responsive images by using .img-responsive class to the <img> tag. This class applies display: block; and max-width: 100%; height: auto; to the image, so that it scales nicely to fit the containing element.
Example 2: Responsive Images
In this example we will make responsive images using .img-responsive class. We will add four images and then apply responsive class by writing the following code.