Loading video...

Video Failed to Load

Go Home

scroll to type with CSS ✨ p { animation: type steps(124); animation-timeline: --main; background: var(--cursor) calc(var(--pos) * 1ch) 0 / 1ch 1lh no-repeat border-box, var(--txt) 0 0 / calc(var(--pos) * 1ch) 100% no-repeat text; } @​keyframes type { to { --pos: 124; }}

117,737 views • 1 year ago •via X (Twitter)

12 Comments

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈1 year ago

here's the @CodePen for this one! 🤙 wanted to tidy a little before postin' it happy to throw together the JavaScript version if you need, the concept is the same ✨

Anima's profile picture
Anima1 year ago

📢It is live! @figma design to @MUI_hq or @AntDesignUI "Whether your design is well organized or a bit chaotic, using standard components or none, Anima takes it all and translates it into high-quality #MUI or #AntDesign code."-->

Ram Maurya's profile picture
Ram Maurya1 year ago

Dang! I feel like I need a crash course on modern CSS

Stefan Roberts's profile picture
Stefan Roberts1 year ago

Honestly every time you post some absolutely mind-blowing CSS it makes me question everything

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈1 year ago

thanks Stefan 🙏

Gustav Ekerot's profile picture
Gustav Ekerot1 year ago

not sure how many times I can say this but: genius

Enterprise Software Architecture's profile picture
Enterprise Software Architecture1 year ago

👀 Beautiful! Syntax highlighting for programming codes would be great.

wallkroft1212's profile picture
wallkroft12121 year ago

Is it possible to get code? I tried to find it on your cdpn, but couldn't

Adrien Duval🇨🇲's profile picture
Adrien Duval🇨🇲1 year ago

Can you do a codepen of this

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈1 year ago

posted it underneath 🤙 gonna add some extra breakdown for it

Mehmet's profile picture
Mehmet1 year ago

Does it work on ios chrome?

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈1 year ago

Chrome doesn't really exist on iOS so not yet But can patch in a snippet of JS to make it work 🤙

Related Videos

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,316 views • 2 years ago