I want an image as the background of the page and I want the content of the page to be scrolled but the image should not move at all.
The CSS code that I have written so far is:
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.5)), url('wallpaper.jpg');
}
As an example, I want my page to look like this template:
https://www.wix.com/website-template/view/html/1896?originUrl=https%3A%2F%2Fwww.wix.com%2Fwebsite%2Ftemplates&tpClick=view_button&esi=c5ca042c-26c4-41cb-bc5f-01e47031976d
I have included an image as the background and made it transparent. I wasn’t able to have the image fixed.
2
Answers
You can achieve this by adding CSS to body
HTML:
You need to remove the background-image from the body.
And add it to a div tag with a position fixed and z-index: -1 to have the content scrollable and over the image. that way you will have the image as a background.
Here is a styling exemple: