Images can be added to the Bootstrap card by simply using an img tag. But we cannot use the same method directly to place an Image Grid into the Bootstrap Card as it will be lead to a misaligned design. Therefore, to get a per-flow to place image Grid into Bootstrap Card. The perfectly aligned grid we need to add some CSS to our HTML code.
Approach: First set the value display: grid; of the div wrapping all the images to transform it into to a grid layout. Then set the value grid-template-columns: auto; of the grid container to specify the number of columns in the grid layout. Now set the value width: 100%; of the image to get a perfect grid.
Below examples illustrate the above approach:
Example 1: Image grid with 2 columns i.e. 2×2 Image grid.
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Card</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= <script src= </script> <script src= </script> <script src= </script> <style> .card { width: 20rem; margin: 2rem; } .image-grid-container { display: grid; /* For 2 columns */ grid-template-columns: auto auto; } img { width: 100%; } </style> </body> <body> <div class="container"> <div class="card"> <div class="image-grid-container"> <img src= <img src= <img src= <img src= </div> <div class="card-body"> <h4 class="card-title">Developer Guy</h4> <p class="card-text"> Developer Guy love to develop front-end and back-end </p> <a href="#" class="btn btn-primary"> See Profile </a> </div> </div> </div> </body> </html> |
Output:

Example 2: Image grid with 3 columns i.e. 3×3 Image grid.
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Cards</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href= <script src= </script> <script src= </script> <script src= </script> <style> .card { width: 20rem; margin: 2rem; } .image-grid-container { display: grid; /* For 3 columns */ grid-template-columns: auto auto auto; } img { width: 100%; } </style> </head> <body> <div class="container"> <div class="card"> <div class="image-grid-container"> <img src= <img src= <img src= <img src= <img src= <img src= <img src= <img src= <img src= </div> <div class="card-body"> <h4 class="card-title"> Developer Guy </h4> <p class="card-text"> Developer Guy love to develop front-end and back-end </p> <a href="#" class="btn btn-primary"> See Profile </a> </div> </div> </div> </body> </html> |
Output:

Recommended Posts:
- Why card images use data-src (not src) for image in Bootstrap 4 ?
- How to display multiple horizontal images in Bootstrap card ?
- How to align images in card with dynamic title?
- Bootstrap 5 | Card
- How to align buttons in Card footer in Bootstrap ?
- How to use links on card-img-overlay class in Bootstrap 4 ?
- How to design Responsive card-deck with fixed width in Bootstrap ?
- Bootstrap 4 | Images
- How to put images in a box without space using Bootstrap?
- Responsive images in Bootstrap with Examples
- Bootstrap 4 | Grid System
- How to Display Validation Message for Radio Buttons with Inline Images using Bootstrap 4 ?
- How to use grid-breakpoint class in Bootstrap ?
- How to Specify Divider gap in Square Grid using Bootstrap ?
- Beginning BootStrap (Part-2) | Grid System
- How Specify Length and Width of Square Grid Picture System in Bootstrap?
- Difference between bootstrap.css and bootstrap-theme.css
- Include Bootstrap in AngularJS using ng-bootstrap
- Bulma | Card
- How to get card vertically centered between search bar and bottom of the viewport?
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.

