<div>
<p>
background-attachment: fixed + filter: bulr() <br />
实现毛玻璃效果
</p>
</div>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
$img: 'https://cloud-static.com/gallery/781718052705_.pic.jpg';
html,
body {
width: 100%;
height: 100%;
background-image: url($img);
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: top;
overflow: hidden;
display: flex;
}
div {
position: relative;
max-width: 460px;
width: 80%;
height: 200px;
margin: auto;
padding: 5vmin;
border-radius: 5px;
border: 2px solid rgba(255, 255, 255, .5);
p {
position: relative;
color: #fff;
z-index: 10;
line-height: 1.5;
}
&::after {
position: absolute;
content: "";
background-image: url($img);
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-position: top;
top: 0;
left: 0;
right: 0;
bottom: 0;
filter: blur(10px);
z-index: 0;
}
}
预览
控制台