我想在背景颜色较暗的 div 中放置一张图片,这也影响了我的图片。我怎样才能将我的图像放在同一个 div 中,但在顶部有一层,这样它就不会受到调光颜色的影响。
.testimonial .cover {
background-color: rgba(0, 7, 11, .87)
}
<div class="testimonial">
<div class="cover"></div>
<img "This is the image i want to be a layer on top">
</div>
最佳答案
此设置:
background-color: rgba(0, 7, 11, .87);
包含一个不透明度参数 (0.87)。此不透明度(部分透明)会影响该 DIV 的内容(例如文本),但不应影响 <img>
中的图像。标签
不过,如果您更改该值 .87
至 1.0
,整体印象肯定会有所不同。
示例:http://codepen.io/anon/pen/PZZOLO 如果您更改背景颜色的不透明度,(浅蓝色)图像不会改变。
关于html - 在没有其属性的 div 中有图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34302546/