Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

CSS text reveal on scroll 📜 <span style="--start: 210; --end: 280;">details</span> span { animation: reveal; animation-timeline: --section; animation-range: contain calc(var(--start) * 1px) contain calc(var(--end) * 1px); } @​keyframes reveal { 0% { opacity: 0.2; }}

165,462 görüntüleme • 2 yıl önce •via X (Twitter)

10 Yorum

jhey ▲🐻🎈 profil fotoğrafı
jhey ▲🐻🎈2 yıl önce

The trick here is using some JavaScript to calculate the "Pixels per character" for the scroll animation 😎 You could do that in a server component or at build time by splitting the text and setting a "Pixels per character" value 🤙

jhey ▲🐻🎈 profil fotoğrafı
jhey ▲🐻🎈2 yıl önce

The neat trick here is making the "Pixels per character" part dynamic and inlining that as a custom property too. Then you could update it for different size viewports 🚀

Heitor Lima profil fotoğrafı
Heitor Lima2 yıl önce

@GianPaneto

🦋 Lankymart profil fotoğrafı
🦋 Lankymart2 yıl önce

Wondow what @adamsilverhq would make of this 🤔

jhey ▲🐻🎈 profil fotoğrafı
jhey ▲🐻🎈2 yıl önce

@adamsilverhq For motion prefs, I'd strip out the animation and sticky part. The text has to be split into separate words but is aria-hidden. Then you can duplicate the text with a screenreader version. Main thing here was to show how to build it as per request 🤙

JV Shah profil fotoğrafı
JV Shah2 yıl önce

Great

chandigarh city profil fotoğrafı
chandigarh city2 yıl önce

Looks great

A L I profil fotoğrafı
A L I2 yıl önce

Where is the code?

2+2=5 profil fotoğrafı
2+2=52 yıl önce

nice 🔥

Umut Akıncı profil fotoğrafı
Umut Akıncı2 yıl önce

its cool

Benzer Videolar

CSS Tip! 🚥 You can create these trending expanding scroll indicators with scroll-driven animations and flex 🤙 .indicator { animation: grow; animation-range: contain calc(50% - var(--size)...; animation-timeline: var(--card); } @​keyframes grow { 50% { flex: 3; }} What's the trick? Put the indicators in a container using flex layout and set a width larger than the number of indicators 😉 .indicators { aspect-ratio: 7 / 1; display: flex; } Importantly, set no gap 🤏 To mimic the gap set a transparent border on each indicator and set the background using padding-box .indicator { background: linear-gradient(#​fff, #​fff) padding-box; border-radius: 50px; border: 4px solid transparent; } Now for the animation. You want to create a view-timeline for each card that moves across 🤙 li:nth-of-type(1) { view-timeline: --one inline; } li:nth-of-type(2) { view-timeline: --two inline; } Make sure they use the inline axis too! The trick is hoisting these view-timeline so the indicators can use them with timeline-scope 👀 .track { timeline-scope: --one, --two, ...; } All that's left is for you to create the animation piece using some calc with the card size ⚡️ .indicator { --size: calc(var(--card-width) * 0.9); animation: grow both linear; animation-range: contain calc(50% - var(--size)) contain calc(50% + var(--size)); } .indicator:nth-of-type(1) { animation-timeline: --one; } .indicator:nth-of-type(2) { animation-timeline: --two; } @​keyframes grow { 50% { flex: 3; }} And there you have it, responsive scroll indicators using CSS scroll-driven animations 😎 Sprinkle a little JavaScript to make them clickable and scroll the the right card ✨ const shift = (event) => { if (event​.target.tagName === "BUTTON") { const index = [...event.target.parentNode.children].indexOf(event​.target); const item = document.querySelector(`li:nth-of-type(${index + 1})`); item.scrollIntoView({ behavior: "smooth", inline: "center" }); } }; As always, any questions or suggestions, let me know. I've put a JavaScript fallback in to use GSAP in browsers that don't have scroll-driven animations 🫶 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

575,634 görüntüleme • 2 yıl önce