Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Future CSS Tip! 🔮 Get creative with scroll-driven animations whilst reusing your keyframes 🤙 li:nth-of-type(odd) { --tr: -1; } img { transform-origin: calc(300% * var(--tr)) 50%; } keyframes rot { from { rotate: -30deg;} to { rotate: 30deg;} } CodePen.IO link below 👇

73,121 Aufrufe • vor 3 Jahren •via X (Twitter)

12 Kommentare

Profilbild von jhey ʕ•ᴥ•ʔ
jhey ʕ•ᴥ•ʔvor 3 Jahren

Here's that @CodePen link! 🚀 Although you'll need to be in Chrome Canary to see it in action ⚠️ That said, this tip applies to CSS animation in general. Try and reuse your keyframes if you can. Use scoped custom properties in them if needs be, etc.

Profilbild von jhey ʕ•ᴥ•ʔ
jhey ʕ•ᴥ•ʔvor 3 Jahren

Saw this great bit of inspo on the @awwwards site and had to see how to create it with CSS scroll driven animations 🤓

Profilbild von Jacob 'kurtextrem' Groß
Jacob 'kurtextrem' Großvor 3 Jahren

@CodePen I feel like this could be an AirBnB page that says 'feeling lucky?', so you scroll though different locations until you find one you like. Nice demo!

Profilbild von jhey ʕ•ᴥ•ʔ
jhey ʕ•ᴥ•ʔvor 3 Jahren

@CodePen That would be neat. I could even see it as a nice portfolio site where each drop is a link to a different page or content, then finish on your contact details and social icons at the end 🤔

Profilbild von Jacob 'kurtextrem' Groß
Jacob 'kurtextrem' Großvor 3 Jahren

@CodePen I realized you've just invented horizontal (almost) infinity scroll 👀

Profilbild von Digizard
Digizardvor 3 Jahren

@CodePen Isn't having all that motion considered not great for accessibility? For people with motion sickness and certain other disabilities?

Profilbild von Asyraf Hussin
Asyraf Hussinvor 3 Jahren

cool!

Profilbild von Anashku
Anashkuvor 3 Jahren

@CodePen @notout82

Profilbild von A L I
A L Ivor 3 Jahren

@CodePen Very inspiring 👍

Profilbild von Marcos Felipe 💾
Marcos Felipe 💾vor 3 Jahren

@CodePen bonito

Profilbild von nszbf
nszbfvor 3 Jahren

@CodePen 🤩

Profilbild von Andrew
Andrewvor 3 Jahren

@CodePen Really nice!

Ähnliche 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,854 Aufrufe • vor 2 Jahren