P粉0681749962023-09-06 12:57:00
Here's a simple example to get you started.
The text in "shot" is in an element on top of the main text. Every time the mouse moves, it will be clipped into a circle at the mouse position. It has a white background so it looks like it's covering the text underneath.
<style> .about { position: relative; --x: -0; --y: -0; font-size: 48px; } .overlay { position: absolute; background: white; top: 0; left: 0; z-index: 1; clip-path: circle(1em at var(--x) var(--y)); color: red; } </style> <div class="about"> <div class="underneath">This is some text <br>and some more</div> <div class="overlay">Different characters<br>and again more</div> </div> <script> const about = document.querySelector('.about'); about.addEventListener('mousemove', function() { const x = event.clientX; const y = event.clientY; about.style.setProperty('--x', x + 'px'); about.style.setProperty('--y', y + 'px'); }); </script>