filter或backdrop-filter实现毛玻璃

时间:2024-12-18 07:01:08
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>毛玻璃</title> <style> * { padding: 0; margin: 0; box-sizing: border-box; } body { width: 100vw; height: 100vh; position: relative; overflow: hidden; display: flex; justify-content: center; align-items: center; background-image: url(./images/); background-position: center; background-repeat: no-repeat; background-size: cover; } h1 { font-size: 5rem; color: #fff; pointer-events: none; text-shadow: 0 10px 20px rgba(148, 147, 147, 0.418); } .mouse_look { position: absolute; transform: translate(-50%, -50%); width: 300px; height: 200px; box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2); background: transparent; backdrop-filter: blur(10px); transition: 0.2s; pointer-events: none; } </style> </head> <body> <h1>丸子Na</h1> <div class="mouse_look"></div> <script> ("mousemove", (e)=>{ const glass = (".mouse_look"); = + "px"; = + "px"; }); </script> </body> </html>