gradient on background image
I want my background image to have a linear-gradient color that goes from left(pink) to right(blue), instead of top to bottom. How can I do this?
code:
body{
background-image:linear-gradient(rgba(198, 115, 115, 0.5),rgba(47, 52, 172, 0.5)),url(people.jpg);
background-repeat: no-repeat;
background-size: cover;
height:100vh;
}
以下是一个简单的例子,如果有任何不清楚的地方,请随时询问:
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.bg-img {
width: 100%;
height: 100%;
background: url("http://unsplash.it/1200x800") center center no-repeat;
background-size: cover;
}
.bg-img:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: linear-gradient(to bottom right, #002f4b, #dc4225);
opacity: .8;
}
<div class="bg-img"></div>
You need to add to right
in your gradient line
Like this:
body{
background-image:linear-gradient(to right, rgba(198, 115, 115, 0.5),rgba(47, 52, 172, 0.5)),url(people.jpg);
background-repeat: no-repeat;
background-size: cover;
height:100vh;
}
body{
background-repeat: no-repeat;
background-size: cover;
height:100vh;
background-image: linear-gradient(to bottom, rgba(198, 115, 115, 0.5) ,rgba(47, 52, 172, 0.5) 100%),url(https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png);
}
链接地址: http://www.djcxy.com/p/89342.html
上一篇: 如何将不透明度设置为div的背景颜色?
下一篇: 在背景图像上的渐变