Firefox不兼容backdrop-filter属性,但总有些需求,真的是。。。
- Firefox用属性background-attachment、background-size可以实现毛玻璃效果
<div class="app">
<div class="box"></div>
</div>
.app{
display: flex;
justify-content: center;
align-items: center;
width: 500px;
height: 240px;
margin: 20px auto;
background: url('./test.jpg') no-repeat;
background-size: contain;
}
.box {
position: relative;
width: 200px;
height: 80px;
text-align: center;
line-height: 80px;
overflow:hidden
}
before伪元素设置背景图片的位置、大小、固定方式,after伪元素负责增加一个rgba的背景色
.box::before{
content: "";
position: absolute;
top: -100px;
left: -100px;
right: -100px;
bottom: -100px;
background: url('./test.jpg') center center no-repeat;
background-attachment: local;
background-size: 500px 240px;
filter: blur(6px);
z-index: -1;
}
.box::after{
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255,255,255,.5);
z-index: 10;
}
Firefox测试如图