-3

Is there a way to put an image as a background with cover size and then right after the image to put a gradient? It will create something like fading. I tried something like this but it doesn't work.

body { 
  height: 100vh;
  background: url('./images/bg.jpg') no-repeat, linear-gradient(180deg, rgba(23,26,25,1) 0%, rgba(0,0,0,1) 100%); 
}
0stone0
  • 34,288
  • 4
  • 39
  • 64
Cloudy Skies
  • 63
  • 2
  • 8

1 Answers1

1

Cover is going to stretch your image to "cover" the background, so you'd never see the gradient anyway, which is also a background image. You could set the gradient as the body's background then using a container DIV with the image background.

CSS:

#container{
  height: 100vh;
  background: url('https://static.vecteezy.com/system/resources/thumbnails/000/299/953/small/y2ok_2cif_180815.jpg') no-repeat;}

body {
  background-image: linear-gradient(180deg, rgba(23,26,25,1) 0%, rgba(0,0,0,1) 100%); 
}

Page:

<div id="container">

    // put page code in here like it was body

</div>
Phaelax z
  • 1,814
  • 1
  • 7
  • 19