



















html
<div class="img-box">
<div class="img"></div>
<div class="img-bg"></div>
</div>
css
.img-box { width: 100%; height: 212px; position: relative; .img { width: 100%; height: 100%; background-position: center; background-repeat: no-repeat; background-size: contain; background-image: url('test.png'); position: relative; z-index: 100; } .img-bg { position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 100%; background-image: url('test.png'); background-size: 200%; /* 放大两倍 */ background-position: center; background-repeat: no-repeat; overflow: hidden; } .img-bg::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); /* 60%不透明度的黑色 */ z-index: 1; /* 确保蒙层在背景之上 */ backdrop-filter: blur(20px); /* 添加20模糊效果 */ }
以上代码因为 img-box 带圆角,在高版本 iOS 系统下,由于 img-bg 的绝对定位会导致 .img继承的圆角会失效。
修改后如下:将 img-bg的决定定位改为相对定位,并放在和 img 同样的位置上。
.img-bg { position: relative; top: -100%; }
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。