Open In App

What is use of the img-fluid Class in Bootstrap ?

Last Updated : 16 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The img-fluid class in Bootstrap is designed for responsive images, ensuring they scale appropriately within their parent containers without overflowing or distorting.

Note: Always include the alt attribute for accessibility and SEO purposes. By applying this class to images, developers ensure that the images seamlessly adjust to the dimensions of their containing elements, preventing undesired overflow or distortion.

Syntax:

<img src="your-image.jpg" class="img-fluid" alt="Responsive Image">

Purpose:

  • Makes images responsive, automatically adjusting their width to fit their container across different screen sizes.
  • Prevents images from exceeding their container width, ensuring a clean and visually harmonious layout.

Key Features:

  • Fluid width: Applies max-width: 100%; and height: auto; to images, enabling responsiveness.
  • Maintains aspect ratio: Preserves the original image proportions to avoid distortion.
  • Cross-browser compatibility: Works consistently across major browsers.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads