Loading video...
Video Failed to Load
CSS Trick! 🤙 You can create gradient borders on translucent elements using mask-clip and mask-composite with a pseudo-element 🔥 .gradient-border::after { mask-clip: padding-box, border-box; mask-composite: intersect; mask: linear-gradient(transparent, transparent), linear-gradient(white, white); } It's the same "Transparent border trick" from before. But, now you apply it to a pseudo-element 😎... show more
269,739 views • 2 years ago •via X (Twitter)
11 Comments

Here's that @CodePen link! 🤙 Should work fine across the board. Tried it out in Chrome, Firefox, and Safari ⭐️ ʕ – ᴥ – ʔ

"Using intersect means that the parts that overlap get replaced." That's actually incorrect. `intersect` means the alphas get multiplied where they intersect. I explained it here in detail a few years back In this case, in the padding area, it's 0*1 = 0.

That's cool, but can you do this?

Yes. Yes I can.

incredible. your comprehensive deconstruction is legendary. this is pushing dev forward.

Did you ever release a solution to have an *animated* gradient border with translucent elements? I think a while back you said that was coming, but I never saw it drop!

this technique right here can handle that 🤙 then you can animate the border with a conic-gradient or using offset-path depending on the type of effect you're looking for ✅ not sure if posted, but definitely spoke about it at Config

Dude.

These demos are awesome, @jh3yy , keep pushing the limits!

Can I Use is saying mask-composite isn't supported?

There's the prefixed version too 🤙 autoprefixer will convert to this 👇 -webkit-mask-composite: source-in, xor; mask-composite: intersect; It does seem to work across the board
