提问人:Chobbit 提问时间:9/14/2023 更新时间:9/15/2023 访问量:72
在Safari中未显示伪背景叠加后
after pseudo background overlay not showing in safari
问:
这仅在Safari上没有在背景图像上显示透明覆盖层的问题,它在所有其他浏览器中都可以正常工作。我浏览了其他建议的问题,甚至尝试了这个问题的修复:[https://stackoverflow.com/questions/21057154/after-pseudo-element-not-working-in-safari][1]但是没有解决它。
因此,我只是有一个相对定位的容器,上面有一个背景图像,一个绝对定位的子 div,它有一个透明的背景颜色覆盖在背景上,最后是一些内容,它位于两者之上。
下面是一个基本示例,说明我需要什么,以及除 Safari 之外的所有功能:
section {
background-image:url('https://www.encompasscorporation.com/wp-content/uploads/2015/09/example-background.jpg');
background-size: cover;
height: 100vh;
position: relative;
width: 100vw;
background-attachment: fixed;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
}
section:after {
content: '';
background: rgb(0 0 0 / 60%);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
section h1 {
color: white;
z-index: 1;
}
<section>
<h1>
Example content
</h1>
</section>
在 Safari 中,深色叠加不起作用,因此浅色背景上的白色文本几乎无法阅读,深色背景上的黑色文本也是如此。
还有其他人有这个问题或可以帮忙吗?
答: 暂无答案
评论