Technology News

Using Position Sticky With CSS Grid

Say you’ve got a two-column CSS grid and you want one of those columns to behave like position: sticky;. There is nothing stopping you from doing that. But the default height for those two columns is going to be “as tall as the tallest content in either column” because the default behavior for grid columns is align-items: stretch;. So, even if you have really “short” content in the column you want to behave as sticky, it won’t appear to move because really it’s already as tall as the other column.

Ahmad Shadeed makes the point that if you want that to work, you’ll probably need to align-items: start; the one you want to behave as sticky.

I would add that if you want

position: sticky; behavior for elements inside either of the columns, then you’ll actually want to leave the default stretch behavior alone. Here’s an example of what I mean there as a fork:

Direct Link →

Standardizing Focus Styles With CSS Custom Properties
It’s beginning to look a lot more expensive for Christmas

Related Articles

14 GEO Conferences to Attend in 2026

14 GEO Conferences to Attend in 2026
Whether you call it GEO, AEO, LLMO, or SEO for AI search, it is a field that barely existed two years ago. Now, it commands its own conference circuit, operating alongside…