Video wird geladen...
Video konnte nicht geladen werden
Fade elements in and out on scroll in a window with CSS? ✅ ul { scroll-padding-inline: 200px; } article { animation: highlight; animation-timeline: view(inline); } @keyframes highlight { entry 0%, exit 100% { opacity: 0; } entry 100%, exit 0% { opacity: 1; } } cc Adam Wathan
222,266 Aufrufe • vor 2 Jahren •via X (Twitter)
10 Kommentare

@adamwathan So cool! I was going through @bramus scroll-driven demos and had keyframe ranges but I couldn't understand how to account for the padding. Turns out scroll-padding is the solution 🤯, you are a genius!

@adamwathan @bramus Yeah, looks like that will do it 🤙 As mentioned, it was late for me last night 😅 Knew there was a cleaner way but mind was blanking haha Glad we got there in the end! I'll do some write ups on all these things soon 🔜

@adamwathan This is so much better than what I used to do: :before and :after div with a gradient from transparent to background, absolutely positioned over the edges of the carousel.

@adamwathan Now do it with Tailwind!

@adamwathan I didn't think it was possible without js. awesome work with so little code.

@adamwathan This mf!!!!!

@adamwathan Can you please drop codepen link 😩😩😩😩

@adamwathan Unfortunately not yet supported on FF / Safari just yet. But still works as progressive enhancement!

@adamwathan Stuff like this would be good for the course 💯 I think it would probably be a good idea to include the tailwind version of animations too, as tailwind is obviously pretty famous (and very handy in react/next), I think that practically speaking, a lot would benefit from it.

@adamwathan the amount of overhead to recreate everything I build in Tailwind too is not something I'm overly into if I'm honest
