how to add background image and gradient in css code example

Example 1: gradient over image css

#linear-gradient-over-image{
    background-image: linear-gradient(to bottom, black, white), 
      url('images/background.jpg');
    background-size: cover;
}

Example 2: background with image and gradient

body {
  background: #eb01a5;
  background-image: url("IMAGE_URL"); /* fallback */
  background-image: url("IMAGE_URL"), linear-gradient(#eb01a5, #d13531); /* W3C */
}

Example 3: linear gradient css background image

background-image: url("IMAGE_URL"), linear-gradient(#eb01a5, #d13531);

Example 4: gradient image css

#show_bg_2 {
 
background-image:
  /*two color gradient over an image*/
linear-gradient(to bottom, rgba(245, 246, 252, 0.52), 
rgba(117, 19, 93, 0.73)),url('images/background.jpg');
 
width: 80%;
height: 400px;
background-size: cover;
}

Example 5: css linear gradient

#grad {
  background-image: linear-gradient(to right, #f1b1b1 , #82e6e8);

}

Tags:

Css Example