Skip navigation
CSS Tip! 📜 You could create a sticky popout bento effect with position: sticky and scroll-driven…
0:00 / 0:42

CSS Tip! 📜 You could create a sticky popout bento effect with position: sticky and scroll-driven…

jhey ʕ•ᴥ•ʔ

@jh3yy149K followers

Visit on X
1,384 likesDownloadOriginal post

342,399 views

CSS Tip! 📜 You could create a sticky popout bento effect with position: sticky and scroll-driven animation 🤩 The trick is to use position: sticky with bottom instead of top like we would usually 🤙 Then we can use scroll-driven animation as a progressive enhancement to fade things and move the phone around ✨ section { view-timeline-name: --section; } .phone { scale: 1.5; translate: 30% 0; animation-name: slip, slide; 👈 2 scroll animations animation-timing-function: linear; animation-fill-mode: both; animation-range: 👈 2 ranges entry 50% entry 60%, exit 10% exit 25%; animation-timeline: --section; } keyframes slip { to { translate: -5% 0; scale: 1 } } keyframes slide { to { translate: -5% 30%; } } If scroll-driven animations aren't supported, we still provide a neat effect using position: sticky alone 😎 The trick to that is having an absolutely positioned card that comes up from beneath the phone image and gives the illusion that they're joined. But, they aren't! CodePen.IO link below! 👇 cc Aaron Stezycki

10 Comments

Comments from the original post on X (Twitter)

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    Here's that @CodePen link! 🚀 Check it out in Chrome for the full effect 🤙 You will still get the sticky popout effect in any browser though as a fallback ✨

    59 likes

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    ✨ New ✨ to the content stream! Got a @remarkablepaper so can share any scribbles/notes from creating stuff etc. 🤩

    15 likes

  • Wali Razzaq's profile picture

    @Wali_Razzaq

    Did you forget to paste @CodePen link? Don't worry @Aarzoo75 is no more on X to steal 😂

    5 likes

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    @CodePen @Aarzoo75 Hahahaha 👏😂

    3 likes

  • bariscc's profile picture

    @baris2c

    Pretty cool. Scale and transform are a bit jaggy/steppy though, wonder there's a way to make them smoother?

    3 likes

  • jhey ▲🐻🎈's profile picture

    @jh3yy

    Partly the nature of the API unfortunately 😔 There is no ease to the scroll. Naturally it feels a little better on a trackpad though 😅

  • Jacob's profile picture

    @jahabeebs

    React devs can also check out react-scroll-parallax to recreate this effect!

    2 likes

  • Apoorv | Plxity's profile picture

    @apoorv_taneja

    this is so cool! loved it

    1 like

  • Jens Mourinho's profile picture

    @jensmourinho

    I like it a lot more when you give hands on examples of things you can do here and now rather then future css tips!

    1 like

  • Gilbert Matos | Nodejs/Nextjs/C#'s profile picture

    @Punisherx6

    man this is so sick!