Gezinmeyi atla
CSS Trick! ⭐️ You can animate your gradient borders by defining types for your custom properties…
0:00 / 0:47

CSS Trick! ⭐️ You can animate your gradient borders by defining types for your custom properties…

jhey ʕ•ᴥ•ʔ

@jh3yy149 B takipçi

X profili
1.387 beğeniİndirOrijinal gönderi

258.918 görüntüleme

CSS Trick! ⭐️ You can animate your gradient borders by defining types for your custom properties with @ property 🔥 1. Define a property @ property --angle { syntax: ' '; /* 👈 type angle*/ inherits: true; initial-value: 0deg; } 2. Animate the value article { animation: rotate 2s infinite linear paused; } @ keyframes rotate { to { --angle: 360deg; } } 3. Use the value in your conic-gradient background. article { --gradient: conic-gradient(from var(--angle), ...); background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--gradient) border-box; border: 4px solid transparent; } 4. Change the play state to running on :hover, etc. article:is(:hover, :focus-within) { animation-play-state: running; } That's it! 🤙 As soon as Firefox 120 lands, this one will work in all browsers! 🙌 Until then, it's a progressive enhancement. You will still get the brightening of the border on hover, etc. That's handled with a pseudo-element ✨ CodePen.IO link below! 👇

11 Yorum

Yorumlar X (Twitter) üzerindeki orijinal gönderiden alınmıştır

  • jhey ▲🐻🎈 profil fotoğrafı

    @jh3yy

    Here's that @CodePen link! 🚀 (Which I may or may have not forgotten to post yesterday 👀) Got the "Final boss" border demo that people have been asking for tomorrow 🤞😅

    14 beğeni

  • Bill Criswell profil fotoğrafı

    @crswll

    I think with this and :has I'll be pretty happy for a while. If I get a :stuck for position: sticky I will dance in the street.

    2 beğeni

  • Danny Clayden Chambers profil fotoğrafı

    @ClaydenChambers

    Now this really is something new to me.. banking this!

    1 beğeni

  • Shaun Levett profil fotoğrafı

    @shaunlevett

    Succulent

    1 beğeni

  • Янус Двуликий profil fotoğrafı

    @Conkur27

    Long time no see thnx

    1 beğeni

  • Blueming profil fotoğrafı

    @forreacting

    Oh wow that looks cool I need this ..thankuuuuuu

    1 beğeni

  • 🙊 Shady Sieo 👹 profil fotoğrafı

    @HgSieo

    Yeah i tried it too to animate some buttons, works fine on nearly square items, as soon as you do more rectangle shapes, the animation seems to slow down on the corners and the shorts edges... Any tips on how to bypass that ? gg anyway !

    1 beğeni

  • jhey ▲🐻🎈 profil fotoğrafı

    @jh3yy

    Got jus' the thing you need 🤙

    10 beğeni

  • lil uzi perf profil fotoğrafı

    @ken_wheeler

    Sheesh

    1 beğeni

  • Lilesh Jadav profil fotoğrafı

    @lileshjadav

    Which tool was that for showing separate layers?

    1 beğeni

  • jhey ▲🐻🎈 profil fotoğrafı

    @jh3yy

    Straight up CSS 🤙