正在加载视频...

视频加载失败

built-in carousel micro-interactions with css scroll-driven animation 🧑‍🍳 li { view-timeline: --item inline } li::scroll-marker { animation: grow linear both; animation-timeline: --item; } progressive enhancement for drag ↓

44,038 次观看 • 1 个月前 •via X (Twitter)

27 条评论

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

saw this pattern ↓ nice candidate for css ::scroll-marker + ::scroll-button combined with scroll animation (falls back to <button> 🤙)

Jake Dohm 的头像
Jake Dohm1 个月前

Is there a modern carousel component/framework based on all this new tech??

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

could throw one together 🤙 never sure how much to include 🤔 have a few scroll demos that you can point an agent at too on my site (web component <draggable-scroll>) include: - drag (inertia) - cyclical - markers - buttons - animation no deps 🚀

Steven van Wel 的头像
Steven van Wel1 个月前

ooeee this is wonderful 👨‍🍳

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

some of these new css things are so so useful 👷

Mehdi · Motionary 的头像
Mehdi · Motionary1 个月前

This looks nice 😍

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

thanks! 🙏

Franklin Williams 的头像
Franklin Williams1 个月前

Nice, if CSS Carousels are supported in all major browsers we will be able to build many carousels as we want.

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

all of the carousels! 😅

Franklin Williams 的头像
Franklin Williams1 个月前

10+/10

Chuks Gabriel 的头像
Chuks Gabriel1 个月前

Smooth and clean 👌

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

🙏🙏

Panos 的头像
Panos1 个月前

Is Horizon theme's codebase a masterclass in using CSS over JS that we could point our LLM to and if no, why?

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

erm – it definitely has some cool things in there 💯 depends what you're looking for!

Panos 的头像
Panos1 个月前

Developing a theme now and want to say to AI: "See how the CSS goat is doing it? Do that."

Paul Murray 的头像
Paul Murray1 个月前

wait so this is *not* scroll-snap? RIP scroll-snap?

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

ha - there is still scroll-snapping 🙌 jus' combined with some of the newer things and scroll-padding to get the snap offset 🧐

freddie 的头像
freddie1 个月前

never ceases to amaze

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

tryin' to get back into the groove 🙏

Jan Nicklas 的头像
Jan Nicklas1 个月前

Oh cool! I was working on sth quite similar: and ran into 3 webkit (iOS18-iOS27) and 1 firefox bugs overflow-x: auto animation timeline firefox (nightly)

jhey ʕ•ᴥ•ʔ 的头像
jhey ʕ•ᴥ•ʔ1 个月前

nice! 😎 yeah, this is why i always try to put a fallback in too. thanks for raising those! 🙏 the little detail where the dots scale out at the edges is a fun one to make, right? you kinda think about it like an invisible extended scrollport but with a container unit 🤓

Jan Nicklas 的头像
Jan Nicklas1 个月前

absolutely… the timeline api is genius!

Jake Hawkes 的头像
Jake Hawkes1 个月前

That is sick! It is one of those ‘I don’t know why I like it but it is perfect’, ironically for both user and dev.

Shaun Simpson 的头像
Shaun Simpson1 个月前

This is beautiful

Max 🇺🇦 的头像
Max 🇺🇦1 个月前

You always fascinate me with your css knowledge and creativity. Great one. ☝️

rusa 的头像
rusa1 个月前

scroll-driven animations finally landing natively is the css feature i've wanted for a decade. carousels without a single line of javascript is the dream we kept faking with intersection observers

Dermache Djamel 的头像
Dermache Djamel1 个月前

Simple and beautiful, as usual from you.

相关视频

Future CSS Tip! 🍏 You can create this Apple-style photo scroller by combining CSS scroll-driven animations and CSS scroll-snap 😍 Peep those changing captions 👀 No JS! img { animation: highlight both linear; animation-timeline: view(inline); 👈 Horizontal animation-range: cover 0% cover 50%; 👈 Finish } @ keyframes highlight { 50% { translate: 0 0; scale: var(--starting-scale); 👈 props opacity: var(--starting-opacity); 👈 } 100% { translate: 0 0; scale: 1; opacity: 1; } } Without the animation support, you get a standard unordered list containing some s 🤙 How do we swap the captions though? The "trick" is to use position: absolute on the figcaption and animate their opacity based on the ViewTimeline of their parent list item 😎 figcaption { animation: show both linear; animation-timeline: --list-item; } @ keyframes show { 0%, 45%, 55%, 100% { opacity: 0; } 50% { opacity: 1; } } li { view-timeline-name: --list-item; view-timeline-axis: inline; 👈 important! } The parent of the scroll track uses position: relative so all the captions sit in the middle even though they are in the right place for the markup 🙌 The last bit is the scroll-snap 🤙 Not much to it at all. Wrap the list and make it scrollable. Then add scroll-snap-type .wrapper { scroll-snap-type: x mandatory; overflow-x: scroll; } Then make sure each list item has scroll-snap-align set on it li { scroll-snap-align: center; } That's it! Pretty cool demo to put together and see how to do this stuff with these APIs 🤓 A lot of cool little tricks to pick up for writing your CSS! ⭐️ CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

234,583 次观看 • 3 年前

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,728 次观看 • 2 年前