Loading video...

Video Failed to Load

Go Home

context-aware css card glow/shine effect ๐Ÿ‘จโ€๐Ÿณ the trick: duplicate and scale the icon. translate it on pointermove. apply feGaussianBlur ๐Ÿค™ check it ๐Ÿ‘‡

841,120 views โ€ข 8 months ago โ€ขvia X (Twitter)

0 Comments

No comments available

Comments from the original post will appear here

Related Videos

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,180,047 views โ€ข 2 years ago