I want to create a background image that will have no effect on other divs in my document. I have this code over here that works great:
body,
html {
height: 100%;
margin: 0;
}
#bg {
/* The image used */
background-color: rgb(0, 0, 0);
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
#heading {
position: absolute;
text-align: center;
vertical-align: central;
width: 40%;
left: 30%;
color: #F82473;
}
<div id="heading">Some stuff</div>
<div id="bg"></div>
But if I switch my divs' order then it's working weird:
body,
html {
height: 100%;
margin: 0;
}
#bg {
/* The image used */
background-color: rgb(0, 0, 0);
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
#heading {
position: absolute;
text-align: center;
vertical-align: central;
width: 40%;
left: 30%;
color: #F82473;
}
<div id="bg"></div>
<div id="heading">Some stuff</div>
How should I paste background image on my website so it won't affect any other divs in my document?