正在加载视频...

视频加载失败

CSS Trick 🤙 You can mask other elements with icons in CSS to create this glittery icon hover/interaction effect ✨ canvas { mask: url(/img/icons/next.svg); } Check this example, inspired by the new Vercel homepage treats that are dropping 🖤 (Had to have a go at whipping this up over...

210,440 次观看 • 2 年前 •via X (Twitter)

10 条评论

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

Here's that @CodePen link! 🚀 This includes the exploded view stuff 💣

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

If you want a standalone version, this one's got you! 👇

Ryan Florence 的头像
Ryan Florence2 年前

@vercel What's a snovra?

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

@vercel I did not see this until I posted it 🤦‍♂️ Now people are pointing it out, I can't unsee it 😂

Eduard Constantin 的头像
Eduard Constantin2 年前

@vercel I think this effect will look even better with this icons

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

@vercel It does look cool! 💯👍

Erfan Ebrahimnia 的头像
Erfan Ebrahimnia2 年前

@vercel Beautiful 😍 Are there performance aspects to consider with multiple canvas elements?

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

For sure! 💯 And that's why I only activate the canvas particles on pointerenter and pointerleave ✨ GSAP has a great utility for this called gsap.ticker where you can control the fps as well as easily add and remove things to the ticker when needed 😎 It saves having to manage requestAnimationFrame yourself 🙌

Aleks 的头像
Aleks2 年前

@vercel Too cool

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

@vercel Now I've got to get back to that tear strip 😩😂

相关视频

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

CSS Tip! 🤙 You can use mask-composite and some JavaScript to create this pointer proximity following glow border ✨ .glow { mask-composite: intersect; mask-clip: padding-box, border-box; mask: linear-gradient(#0000, #0000), conic-gradient(#0000 0deg, #​fff, #0000 45deg); } The trick is to mask a background-image with a combination of mask layers. mask-composite: intersect; means the mask used will be the intersection of the layers 🔥 use source-in, xor; in browsers that don't support intersect; In this demo, you can use pseudoelements and rely on scoped custom properties to do a lot of the heavy lifting for you 🙌 Once you've masked the background, you need to update the starting angle of the conic-gradient on pointermove 👆 You can work that out by getting the center point of each card and then calculating the angle between that and the pointer with Math.atan2 🤓 let ANGLE = Math.atan2( event?.y - CARD_CENTER[1], event?.x - CARD_CENTER[0] ) * 180 / Math.PI ANGLE = ANGLE < 0 ? ANGLE + 360 : ANGLE; CARD.​style.setProperty('--start', ANGLE + 90) You plug that into your conic-gradient mask as a custom property accounting for --spread ⚡️ conic-gradient(from calc((var(--angle) - (var(--spread) * 0.5)) * 1deg), #000 0deg, #​fff, #0000 calc(var(--spread) * 1deg)); To get the blur, you apply a blur to the glow container on each card 🤙 .glows { filter: blur(calc(var(--blur) * 1px); } That's it! Layers of masks that are clipped and composited before being blurred 😎 The added trick is to fade each one in when the pointer is in the defined proximity of the card. For example, don't show unless within 100px of a card. You can see that in the video. Check out the JavaScript code for that 🫶 Couldn't resist making this one 😁 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

1,179,810 次观看 • 2 年前