Пропустить навигацию
Future CSS Tip! 🍏 You could create those Apple-style dynamic CTA reveals with container style…
0:00 / 0:22

Future CSS Tip! 🍏 You could create those Apple-style dynamic CTA reveals with container style…

jhey ʕ•ᴥ•ʔ

@jh3yy146 тыс. подписчиков

Открыть в X
1 336 отметок «Нравится»СкачатьОригинальный пост

180 875 просмотров #AppleEvent

Future CSS Tip! 🍏 You could create those Apple-style dynamic CTA reveals with container style queries and scroll-driven animations with zero JavaScript 👀 (Sticking to the #AppleEvent theme) .cta { animation: activate both, activate reverse; animation-timeline: --section, view(); animation-range: entry, cover 50%; } keyframes activate { 0% { --active: 0; } 100% { --active: 1; } } @ container style(--active: 1) { .cta__bloom { scale: 0.99; transition: scale 0.5s var(--back); /* 👈 linear() */ } .cta a { scale: 1; grid-template-columns: var(--content-size, auto) 36px; transition: scale 0.2s 0s, grid-template-columns 0.5s 0.6s var(--elastic); } } There's a fair bit of code here 🤯 But, the idea is this... 1. Use a scroll-driven animation scoped to each section for each CTA to change a custom property value (--activate) between 1 and 0. 2. Use a container style query to dictate the transition sequence for each moving part making use of transition-delay. 3. Make use of linear() easing to get the right effect ⚡️ It's wild to put all these APIs together and see what's possible. There are likely some spots to tidy this up 💯 These are powerful combinations for sure though! 💪 CodePen.IO link below! 👇

10 комментариев

Комментарии из оригинального поста в X (Twitter)

  • Фото профиля jhey ʕ•ᴥ•ʔ

    @jh3yy

    Here's that @CodePen link! 🚀 You'll need to be in Chrome 115+ to see everything working as it should 🤞 We're combining: – Scroll-driven animation – linear() easing – Container style queries

    32 отметки «Нравится»

  • Фото профиля jhey ʕ•ᴥ•ʔ

    @jh3yy

    Missed the details around linear() easing functions? Here's the post I made about them 😉 The @smashingmag article should be landing this week I think 🤔

    18 отметок «Нравится»

  • Фото профиля jhey ʕ•ᴥ•ʔ

    @jh3yy

    @smashingmag Want to read about how to combine container-style queries with scroll-driven animations? 🤓 @bramus has you covered 👇 In fact, I'm not sure dictating the transition steps as they have been done in this demo would work going down the `calc` route 🤔

    18 отметок «Нравится»

  • Фото профиля jhey ʕ•ᴥ•ʔ

    @jh3yy

    Only went and uploaded the wrong video 🤦‍♂️😅

    8 отметок «Нравится»

  • Фото профиля ❮λ❯ Elefunc 🌐

    @Elefunc

    🎁 Upgrade to @RTCode_io ↓ ⚡️ see your changes in real-time ⌨️ adjust selected numbers with ↑↓ keys ⋯ no waits/no reloads Swap codepen .io /⋯/pen/⋯ with ↓ xcodepen

    2 отметки «Нравится»

  • Фото профиля OBODUGO

    @theKofacts

    🫡🫡 great, as usual!

  • Фото профиля Javier Balvin Lau

    @JavierBalvinLau

    @SaveToNotion #Tweets

  • Фото профиля Vamsi Krishna

    @bettercal_babbu

    Advanced Css tips

  • Фото профиля Ashraf Chowdury

    @ashraf_chowdury

    Wow, it looks magnificent 😍 Great share, jhey 👏

  • Фото профиля Matt

    @uixmat

    Gunna be a game changer for hen this has full support