Пропустить навигацию
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 тыс. подписчиков

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

258 918 просмотров

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 комментариев

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

  • Фото профиля jhey ▲🐻🎈

    @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 отметок «Нравится»

  • Фото профиля Bill Criswell

    @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 отметки «Нравится»

  • Фото профиля Danny Clayden Chambers

    @ClaydenChambers

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

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

  • Фото профиля Shaun Levett

    @shaunlevett

    Succulent

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

  • Фото профиля Янус Двуликий

    @Conkur27

    Long time no see thnx

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

  • Фото профиля Blueming

    @forreacting

    Oh wow that looks cool I need this ..thankuuuuuu

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

  • Фото профиля 🙊 Shady Sieo 👹

    @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 отметка «Нравится»

  • Фото профиля jhey ▲🐻🎈

    @jh3yy

    Got jus' the thing you need 🤙

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

  • Фото профиля lil uzi perf

    @ken_wheeler

    Sheesh

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

  • Фото профиля Lilesh Jadav

    @lileshjadav

    Which tool was that for showing separate layers?

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

  • Фото профиля jhey ▲🐻🎈

    @jh3yy

    Straight up CSS 🤙