Search code examples
cssbackgroundopacity

CSS: Semi-transparent background and an image


body {
  background-image: url('cloud.png');
  background-color: rgba(255, 255, 255, 0.6);
}

I tried using the above to produce a semi-transparent white background above a background-image. It doesn't work, only the background image is shown and the background-color appears to be ignored. How can I adjust the opacity of a body background image?


Solution

  • background-color is placed underneath background-image, not above it (when rendered in the web-browser). To put a semi-transparent white block over an image, you will need to place another different HTML element on top of it with background-color.