Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to fit a image in all the empty space using css grid?

New member
Joined
Feb 9, 2023
Messages
8
I try to fit my pic in my sidebar of web page but it showing empty space how to fit one image in one row using css grid? I tried grid_column start 1 And grid column end 3?
 
New member
Joined
Feb 9, 2023
Messages
8
Define the grid layout for that container and then specify the size and position of the image within that layout.

Code:
<div class="grid-container">
  <img src="your-image-url.jpg" class="grid-item">
</div>

Code:
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto;
}

.grid-item {
  grid-column: 1 / 3;
  width: 100%;
  height: auto;
}
 
Top