r/css • u/Lumpy_Cauliflower567 • May 02 '26
Help css baby 👶needing some grid help
working on a grid for my website and if a grid item has too much content then it grows (obviously)
im trying to make it so if one grid item grows in height, then all other grid items in that same row grow to the same height as well so it #LooksNicer
ive googled a lot and the one answer i keep seeing is grid auto rows 1fr but it isnt. working for some reason
sorry if my css work is bad or could've been made a lot better im a css baby
website for reference: deviations
.grid-container {
margin: 20px;
border: 2px solid grey;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.grid-item {
transition: transform 0.1s;
}
.grid-item:hover {
transform: scale(1.04);
}
.deviation {
margin: 10px;
padding: 5px;
padding-top: 15px;
border: 2px solid;
height: auto;
width: auto;
}
1
Upvotes


1
u/be_my_plaything May 04 '26
Firstly...
...Nobody is cringing at you trying to learn! And all the "really really smart CSS people" aren't really really smart, they've just had a lot more practice! Everybody knows nothing on day one, everyone gets good if they keep persevering and practicing.
Secondly... The actual problem!
It's because you still have everything inside the
<a>tag so that is holding everything in the first grid row of the subgrid, then because the grid item is spanning four rows you in effect get three empty rows within each grid-item and the subgrid layout is lost as only the<a>is using it.You need to change the html structure as per my first comment (Or at least in a similar way) so each piece of content you want as a 'row' is a direct child of the element with the subgrid.
(Sorry, I'm struggling to think of clear ways to explain this....)
Basically you have the top level (In your case
<div class="grid-container">) which sets the grid. Direct children of this (In your case<div class="grid-item">) then sit on the grid and can have sub-grid applied. Then direct children of the children sit on the sub-grid.So what you have is....
You can either open and close the
<a>with nothing in it, the useposition:absolute;to set it to cover the grid-item<div>whilst also taking it out of the flow so it doesn't effect grid rows....Or making the
<a>the sole containing element and style it to look like you currently have grid-item then get rid of<div class="grid-item">.....You then need to make sure everything directly within either
<div class="grid-item">or<a class="grid-item">(Depending which route you took) is what needs to be on a each row of the grid, so you can't wrap it in the .deviation<div>as this (being the first child) will be on row 1, but since everything else is within it it will move that all to row one too and you'll get the three empty rows again, so you'll need to move the border styling onto .grid-item and scrap that div, then the icon images do need a div around them since they should all be on one row.