您好,欢迎访问一九零五行业门户网

css背景图片颜色怎么设置

css中,可以利用background和background-blend-mode属性来设置背景图片颜色,语法格式“background: url(背景图片路径), 颜色值;background-blend-mode: lighten;”。
本教程操作环境:windows7系统、css3&&html5版、dell g3电脑。
利用background-blend-mode
代码如下:
<!doctype html><html><head><meta charset="utf-8"><style>.icon1 {width: 180px;height: 180px;background: url(img/1.jpg);background-size: cover;}.icon2 {width: 180px;height: 180px;background: url(img/1.jpg), linear-gradient(#f00, #c10);/* background: url(img/1.jpg),red; */background-blend-mode: lighten;background-size: cover;}</style></head><body><div>原图:</div><br /><div></div></body></html>
效果图:
说明:
lighten这个混合模式:变亮、变亮模式与变暗模式产生的效果相反,黑色比任何颜色都要暗,所以黑色会被任何色替换掉。反之,如果素材的底色是黑色,主色是白色。那就应该用变暗(darken)的混合模式  。
linear-gradient(#f00,  #00f )还可以实现渐变颜色的效果哦。
(学习视频分享:css视频教程)
以上就是css背景图片颜色怎么设置的详细内容。
其它类似信息

推荐信息