Загрузка видео...

Не удалось загрузить видео

На главную

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

191,373 просмотров • 1 год назад •via X (Twitter)

Комментарии: 10

Фото профиля Brotzky
Brotzky1 год назад

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
Λbstract1 год назад

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
Brotzky1 год назад

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

Фото профиля Adam Wathan
Adam Wathan1 год назад

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
alex1 год назад

elite

Фото профиля Brotzky
Brotzky1 год назад

now u r too

Фото профиля Vini
Vini1 год назад

mask is also pretty good to create that fade out effect

Фото профиля T. Costa
T. Costa1 год назад

This is the way

Фото профиля Robert Menke
Robert Menke1 год назад

✍️✍️✍️

Фото профиля matt
matt1 год назад

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

Похожие видео

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 просмотров • 2 лет назад