重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

使用css3怎么给背景图片加颜色遮罩

这篇文章给大家介绍使用css3怎么给背景图片加颜色遮罩,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

永善ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:13518219792(备注:SSL证书合作)期待与您的合作!

方法一:通过定位叠加(注意层级)


      
.wrap1 {     position: relative;     width: 1200px;     height: 400px;     background: rgba(0, 0, 0, .5); } .wrap1 .inner {     position: absolute;     left: 0;     right: 0;     top: 0;     bottom: 0;     background: url(ban8.jpg) no-repeat center center;     background-size: cover;     z-index: -1; }

方法二:通过伪类元素叠加

.wrap2 {     position: relative;     width: 1200px;     height: 400px;     background: url(ban8.jpg) no-repeat center center;     background-size: cover; } .wrap2::before {     content: "";     position: absolute;     left: 0;     right: 0;     bottom: 0;     top: 0;     background-color: rgba(0, 0, 0, .5);     z-index: 2; }

方法三:CSS3颜色叠加background-blend-mode:multiply;(正片叠底)


.wrap3 {
    position: relative;
    width: 1200px;
    height: 400px;
    background: url(ban8.jpg) rgba(0, 0, 0, .5) no-repeat center center;
    background-blend-mode: multiply;
}

拓展:背景模糊加颜色叠加

使用css3怎么给背景图片加颜色遮罩

.wrap4 {
    position: relative;
    width: 1200px;
    height: 400px;
    background: url(ban8.jpg) rgba(0, 0, 0, .5) no-repeat center center;
    background-blend-mode: multiply;
    filter: blur(2px);
    overflow: hidden;
}

关于使用css3怎么给背景图片加颜色遮罩就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


新闻名称:使用css3怎么给背景图片加颜色遮罩
浏览地址:http://cqcxhl.com/article/gccpop.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP