正在加载视频...

视频加载失败

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 年前