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

What’s New in Node.js 20

What’s New in Node.js 20
Version 20 of Node.js was released on 18 April 2023. It addresses some issues and criticisms already “solved” by Deno and Bun, including a new permission model and a stable…

2021 Scroll Survey Report

2021-scroll-survey-report
Get the 2021 Scroll Survey Report plus words from the Chrome team about how this impacts priorities and plans for Chromium and the web. Aug 2, 2021 • Updated Sep…

Facebook is having a Big Oil moment

facebook-is-having-a-big-oil-moment
Sen. Richard Blumenthal mentioned a familiar metaphor in the Facebook whistleblower hearing on Tuesday. “Facebook and Big Tech are facing their Big Tobacco moment,” he said, arguing that the social…