实现鼠标悬浮显示中间,模糊四周
HTML
<!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="main.css">
<title>Document</title>
</head>
<body>
<section>
<div class="layer1"></div>
<div class="layer2"></div>
</section>
</body>
</html>
CSS
body {
margin: 0;
padding: 0;
}
section {
width: 100%;
height: 100vh;
}
section .layer2 {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url(bg1.jpg) no-repeat;
background-attachment: fixed;
background-position: center;
background-size: 1920px 1200px;
transition: 1s;
}
section .layer1 {
position: absolute;
top: 50%;
left: 50%;
width: 900px;
height: 750px;
transform: translate(-50%, -50%);
background: url(bg1.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: 1920px 1200px;
transition: 1s;
z-index: 1
}
.layer1:hover ~ .layer2
{
filter:blur(10px)
}
.layer1:hover {
box-shadow: 0px 25px 60px rgb(0, 0, 0.8);
}