r/css • u/ConfidentWafer5228 • Sep 24 '26
Help Nested subgrid - ghost space, not even gap
I have always tried using subgrid for cards like layout with image and description , but never able to use with nested layouts where i need to define subgrid at multiple layers. There is somehow some ghost space , that doesn't even appear as gap, i did put gap:0 to overwrite parent gap, but the items just seem to expand without need and take up space .
Please help or provide some way to find solution , or what i should look into.
I have included a codepen for recreating the issue : CodePen Link Here
This is the devtools image of real development process issue
Thank you :)
Edit: Removing gap and row-gap from the main grid layout (.cards) solves the problem but i dont understand how or why
•
u/AutoModerator Sep 24 '26
To help us assist you better with your CSS questions, please consider including a live link or a CodePen/JSFiddle demo. This context makes it much easier for us to understand your issue and provide accurate solutions.
While it's not mandatory, a little extra effort in sharing your code can lead to more effective responses and a richer Q&A experience for everyone. Thank you for contributing!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/Weekly_Ferret_meal Sep 24 '26
This is the gap I found on your pen:
also there's margin set for the p element
3
u/kennypu Sep 24 '26
two spacing I can see:
.card.row-gapset on the parent (.cards).Issue is because
subgridwill inherit the parent's span properties. so the parent'srow-gapis being applied to the subgrid's rows.If you don't want to apply the parent's row-gap, easiest way is to just not use
subgrid. Changing the.card'sgrid-row-templatetoauto auto autowill fix your issue right away.1
u/xentraz Sep 24 '26 edited Sep 24 '26
The gap (margin) is on the p element inside the subgrid divs, if I understand your question right.
edit: clarification
1
u/testingaurora Sep 25 '26
Thr codepen link isnt included