在背景图像上的渐变

我希望我的背景图像具有从左(粉红色)到右(蓝色)的线性渐变颜色,而不是从上到下。 我怎样才能做到这一点?

码:

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>

您需要在渐变线中to right添加

喜欢这个:

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/89341.html

上一篇: gradient on background image

下一篇: gradients for background