Created
October 27, 2025 18:07
-
-
Save wookiehangover/da0723f678028bae9c9cf8827760b900 to your computer and use it in GitHub Desktop.
scroll fog effect (credit to jhey)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @supports (animation-timeline: scroll()) { | |
| :root { | |
| --scroll-fog-size: 120; | |
| } | |
| .scroll-fog { | |
| animation: | |
| mask-up both linear, | |
| mask-down both linear; | |
| animation-timeline: scroll(self); | |
| animation-range: | |
| 0 calc(var(--scroll-fog-size) * 1px), | |
| calc(100% - (var(--scroll-fog-size) * 1px)) 100%; | |
| mask: | |
| linear-gradient(white, transparent) 0 0 / 100% 0 no-repeat, | |
| linear-gradient(white, white) 0 50% / 100% 100% no-repeat, | |
| linear-gradient(transparent, white) 0 100% / 100% | |
| calc(var(--scroll-fog-size) * 1px) no-repeat; | |
| mask-composite: exclude; | |
| } | |
| @keyframes mask-up { | |
| to { | |
| mask-size: | |
| 100% calc(var(--scroll-fog-size) * 1px), | |
| 100% 100%; | |
| } | |
| } | |
| @keyframes mask-down { | |
| 100% { | |
| mask-size: | |
| 100% calc(var(--scroll-fog-size) * 1px), | |
| 100% 100%, | |
| 100% 0; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main trick is lifted from jhey:
Puts a mask over your element, reveals when scroll starts / stops.