Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

For your stacked elements: Stop using border or box-shadow. Start using mask.

191,373 görüntüleme • 1 yıl önce •via X (Twitter)

10 Yorum

Brotzky profil fotoğrafı
Brotzky1 yıl önce

There are always issues when you use box-shadow, border, or outline for this. You forget to change the color so it mismatches the background. You want to add hover interactions so you need to transition both. The CSS is quite simple:

Λbstract profil fotoğrafı
Λbstract1 yıl önce

RT @InstaMAT_io: 👀 Are you looking for an alternative to Adobe Substance tools? Do not miss out on InstaMAT from killer node-based material…

Brotzky profil fotoğrafı
Brotzky1 yıl önce

Another wonderful trick: clip-path with SVGs. It's a lot easier to customize in tools like Figma as well.

Adam Wathan profil fotoğrafı
Adam Wathan1 yıl önce

I had to give up on this approach when I wanted to be able to make an avatar translate up on hover and stuff like that — found any solution to that set of problems?

alex profil fotoğrafı
alex1 yıl önce

elite

Brotzky profil fotoğrafı
Brotzky1 yıl önce

now u r too

Vini profil fotoğrafı
Vini1 yıl önce

mask is also pretty good to create that fade out effect

T. Costa profil fotoğrafı
T. Costa1 yıl önce

This is the way

Robert Menke profil fotoğrafı
Robert Menke1 yıl önce

✍️✍️✍️

matt profil fotoğrafı
matt1 yıl önce

Working on a stacked cards design and gonna get rid of the box-shadows and try this!

Benzer Videolar

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 😎 The trick is to create a pseudo-element with a gradient background and then mask it so we only see the part we want, the border ✨ mask-clip defines the area affected by a mask. Similar to how you can define background-size. Using padding-box and border-box constrains the two masks. mask-composite is the magic part ✨ It defines a compositing operation for stacked mask layers. Using intersect means that the parts that overlap get replaced. And this seems to work in all browsers 🙌 As for the rest of the styles... – Make sure you set pointer-events: none on the pseudo-element – Make sure it fills the parent element. You can use position: absolute and inset: 0 – Make sure the background fills the space including the border-width. You can use calc to achieve that: --bg-size: calc(100% + (2px * var(--border))); background: var(--gradient) center center / var(--bg-size) var(--bg-size); That's it! 🚀 Gradient borders on translucent elements. You can set all the backdrop-filter: blur() you like! 😅 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

269,739 görüntüleme • 2 yıl önce