html無法實現導航欄毛玻璃效果?
這種效果嗎?直接上代碼。
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>毛玻璃</title>
<style type="text/css">
* {
margin: 0px;
padding: 0px;
}
html,
body {
width: 100%;
height: 100%;
}
.main {
width: 100%;
height: 100%;
position: relative;
background: url(img1.jpg) center top;
background-size: cover;
}
.content {
width: 800px;
height: 400px;
position: absolute;
top: 50%;
left: 50%;
overflow: hidden;
margin-top: -200px;
margin-left: -400px;
border-radius: 10px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
z-index: 100;
padding: 50px;
box-sizing: border-box;
/*不會把盒子撐開*/
}
.content::before {
content: "";
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
z-index: -1;
/*-1 可以當背景*/
filter: blur(20px);
margin: -30px; /*消除邊緣透明*/
background: url(img1.jpg) center top;
background-size: cover;
/*平鋪*/
background-attachment: fixed;
/*位置固定*/
}
</style>
</head>
<body>
<div>
<div>
</div>
</div>
</body>
</html>