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. 2x2 Image grid.
Output:
👁 Image
Example 2: Image grid with 3 columns i.e. 3x3 Image grid.
Output:
👁 Image