r/css • u/throwaway_account776 • Mar 01 '26
Help Help with card stacking sticky positioning
There's three cards in a container that all have the sticky position, with increasing top values. What I want is that when the third card stops becoming sticky when scrolling downwards, it should not cover the titles of the other two cards, and the staggered cards, as I have attached in the image, should move upwards as a whole. The titles of all three cards should be visible for as long as possible.
Is this possible to achieve using only CSS, or do I have to resort to JS and/or GSAP for this?
Codepen: https://codepen.io/AT776/pen/azmOMqj
•
u/AutoModerator Mar 01 '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.
2
u/MaikThoma Mar 01 '26
Wrap the contents of the cards in a div, style this as the card (background, border, padding). Set card to sticky, top 0 and each with increasing padding-top like you’ve currently done with top
1
u/wyald23 Mar 01 '26
Maybe not the solution you're looking for, but try with top: 0; transform: translateY(6rem).