subgrid vs inherit
Is anyone aware how using
grid-template-columns: subgrid;
differs from
grid-template-columns: inherit;
?
Yous think if they were exactly the same, they wouldn't spend so much time developing subgrid. I know gap
is auto inherited from subgrid
, but not sure if inherit
also inherits gap
.
Does anyone have any insight or links to resources?4 Replies
inherit will only take the value of the parent, nothing more
It wont make it a grid (there for you need a display: grid) and even if you set it, it won't be a subgrid (just a grid on its own)
Oh I thought you still needed
display:grid
on the child when using subgrid 🤣
when you say “it won’t be a subgrid, just a grid on its own” what does that mean though? What benefits does it get from subgrid (beyond not having to display:grid
on the child? )Subgrid will actually adhere to the colums/row lines of the parent grid
Kevin has some videos about it, check them out for a basic understanding
Got it. Thank you. It basically creates a relationship between the two instead of just having two separate grids with the exact same values ?
For anyone else wondering, even if you do inherit, the content inside takes up more or less space so 1fr is dealing w the space that’s left. Since it’s usually not exact equal characters or lines of content , it won’t line up. When declaring Subgrid its now seeing that 1fr as the same unit of space.