css怎么将背景颜色显示在背景图片上面

html-css09

css怎么将背景颜色显示在背景图片上面,第1张

<div style="width:640pxheight:320pxbackground-image: linear-gradient(to top,rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(背景图片url)"></div>

<div style="width:800pxheight:600pxbackground:url(https://www.taopic.com/uploads/allimg/130427/240403-13042F61F080.jpg) no-repeat center / cover">背景图

<div style="width:400pxheight:200pxmargin:200px autobackground-color:rgba(0,0,0,0.5)color:#ffftext-align:centerline-height:200px">这是文字这是文字</div>

</div>

已经用css定义了背景,添加图片使图片颜色与背景颜色一致,首先颜色,先确定好一种颜色,做为最终的颜色,修改图片的背景图片,可以去使用ps将背景颜色去掉,添加确定好的颜色,或者在是在css中修改背景颜色也是可以,具体看代码:

<html>

<head>

<style>

#div1{

width:960px

height:200px

background-color:#f00

background:url('图片地址')

}

</style>

</head>

<body>

<div id='div1'>

<p>我是测试文字</p>

</div>

</body>

</html>