PX Forums demoYou are browsing as a visitor. Try it as: Member · Moderator · AdminOne click, no password. All changes are reset every night at 03:45 CET.
Skip to content

CSS grid layout for the blog list: share your tricks

Log in
Replies
13
Voices
14
Views
507
Last activity
Yuki Tanaka Topic starter Member375 karma45 posts · Joined Dec 2026

I rebuilt my blog list with grid and it is so much cleaner than the float version. Here is my base:

.post-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1.5rem;
}
.post-list > article { container-type: inline-size; }

What patterns do you use?

Choose a reaction
Reply
Maya Okonkwo Moderator540 karma57 posts · Joined Dec 2026

Have you tested it with a long title? It might wrap awkwardly on small screens.

Choose a reaction
Reply
Priya Nair Expert878 karma62 posts · Joined Dec 2026

I like how restrained this is. Less really is more.

Choose a reaction
Reply
Diego Alvarez Member147 karma34 posts · Joined Dec 2026

A trick that helped me: design the mobile layout first, then add columns as the screen grows.

Choose a reaction
Reply
Mei Lin Member449 karma40 posts · Joined Dec 2026

Thanks for sharing. Could you post the CSS for the header?

Choose a reaction
Reply
Amara Diallo Helper475 karma52 posts · Joined Dec 2026

I would increase the contrast a bit; the grey text fails AA on the white background.

Choose a reaction
Reply
Aisha Khan Member302 karma32 posts · Joined Dec 2026

Looks good! The spacing between the cards is really nice.

Choose a reaction
Reply
Lena Fischer Member237 karma28 posts · Joined Dec 2026

Great tip, I did not know that.

Choose a reaction
Reply
Nora Bergström Member225 karma42 posts · Joined Dec 2026

Here is the variable I use for spacing:

:root { --space: clamp(1rem, 2.5vw, 2rem); }
Choose a reaction
Reply
Rafael Santos Member406 karma30 posts · Joined Dec 2026

Not the answer you want, but I stopped worrying about it once I wrote the steps down as a checklist.

Choose a reaction
Reply
Hannah Lindqvist Moderator597 karma46 posts · Joined Dec 2026

Ha, I could have written this. Subscribing to see what others say.

Choose a reaction
Reply
Sofia Ricci Helper759 karma59 posts · Joined Dec 2026

@demo-nora ↗:

Here is the variable I use for spacing:

:root { --space: clamp(1rem, 2.5vw, 2rem); }

That matches my experience too, with one difference: I do it on a copy first.

Choose a reaction
Reply
Lucas Meyer Expert852 karma57 posts · Joined Dec 2026

I tried the opposite approach last year and regretted it. Here is what I learned:

  • Keep it boring.
  • Write it down.
  • Revisit it every quarter.
Choose a reaction
Reply
Elena Petrova Helper577 karma41 posts · Joined Dec 2026

Late to the party, but this thread is a gold mine. Bookmarked.

Choose a reaction
Reply