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:
from CSS-Tricks https://ift.tt/3lTdSNt
via IFTTT
No comments:
Post a Comment