点击查看html编辑器说明文档

使用 background-attachment 实现毛玻璃效果edit icon

|
|
Fork(复制)
|
|
提交反馈
嵌入
设置
下载
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ...
展开
</head>
<body>
<div>
    <p>
        background-attachment: fixed +  filter: bulr() <br />
        实现毛玻璃效果
    </p>
</div>
</body>
SCSS
格式化
$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;
    }
}
JS
格式化
预览
控制台