简体   繁体   English

在页脚中覆盖有背景颜色的背景图像

[英]Background-image overlayed with background-color in footer

Is there any possibility to have background-image overlayed with background-color in footer? 在页脚中是否有可能使背景图像与背景颜色重叠?

<footer class="layout_footer">
...
</footer>

.layout_footer{
  background-image: url('./../images/footer.jpg');
  background-size: cover;
  background-color: rgba(0,0,0,0.6); 
 }

You can use linear-gradient with your background image. 您可以对背景图像使用linear-gradient I added height:100px just for demonstration. 我添加了height:100px只是为了演示。

Browsers will treat linear-gradient as an image and will stack it with your actual image. 浏览器会将linear-gradient视为图像, 并将其与您的实际图像堆叠在一起。

 .layout_footer { background-image: linear-gradient(0deg, rgba(255, 0, 0, 0.6), rgba(255, 0, 0, 0.6)), url('http://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg'); background-size: cover; height: 100px; } 
 <footer class="layout_footer"> ... </footer> 

you can do with this :after css property 您可以使用此:after CSS属性

 .layout_footer{ background-image: url('https://www.gravatar.com/avatar/b962594a4e8d0aa2219d0b5e15f72c39?s=32&d=identicon&r=PG&f=1'); background-size: cover; position:relative; height:200px; width:200px; } .layout_footer:after { content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: 0; background-color: rgba(0,0,0,0.6); } 
 <footer class="layout_footer"></footer> 

This should do the trick :). 这应该可以解决问题:)。

layout_footer {
    opacity: 0.4;
    background-color: #000000;
    background-image: url('./../images/footer.jpg');
 }
.layout_footer{
  background-blend-mode: overlay;
  background-image: url('./../images/footer.jpg');
  background-size: cover;
  background-color: rgba(0,0,0,0.6);

}

This is from https://css-tricks.com/tinted-images-multiple-backgrounds/ 这来自https://css-tricks.com/tinted-images-multiple-backgrounds/

.tinted-image {
  background: 
    /* top, transparent red, faked with gradient */ 
    linear-gradient(
      rgba(255, 0, 0, 0.45), 
      rgba(255, 0, 0, 0.45)
    ),
    /* bottom, image */
    url(image.jpg);
}

Change the color and paths to your choice 更改颜色和路径以选择

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM