![在这里插入图片描述](https://img-blog.csdnimg.cn/1ef18aa05ec146f9ad3c620eaaa78369.gif#pic_center)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/frosted-glass.css">
<title>Document</title>
</head>
<body>
<section>
<h2>Frosted Glass</h2>
<div class="glass"></div>
</section>
<script>
document.addEventListener('mousemove', function (e) {
const glass = document.querySelector('.glass')
glass.style.left = e.offsetX + 'px'
glass.style.top = e.offsetY + 'px'
})
</script>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
section {
position: relative;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: url("../images/back2.jpeg");
background-position: center;
background-attachment: fixed;
background-size: cover;
overflow: hidden;
}
section h2{
font-size: 5em;
color: white;
pointer-events: none;
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
section .glass{
position: absolute;
transform: translate(-50%,-50%);
pointer-events: none;
width: 300px;
height: 200px;
text-shadow: 0 25px 50px rgba(0,0,0,0.2);
background: transparent;
backdrop-filter: blur(10px);
transition: 0.2s;
}