这可能吗?要在一个 div 上覆盖 和 背景图像?如:
div {
color: white;
background-color: hsla(15, 92%, 13%, 0.79);
height: 500px;
background-image: url('http://via.placeholder.com/500x500');
}
<div>
<p>Content goes here</p>
</div>
谢谢!
最佳答案
你可以像这样使用伪元素:
div {
position: relative;
color: white;
background-image: url('http://via.placeholder.com/500x500');
height: 500px;
}
div:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
background: hsla(15, 92%, 13%, 0.79);
z-index: 0;
}
p {
position: relative;
z-index: 2;
}
<div>
<p>Content goes here</p>
</div>
关于html - 在同一个 div 上叠加颜色和背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47441509/