- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hello.
I am still getting use to multi class.
The question is.
if I have a container and has content inside which has own backgounds.
When I first tried to set background to container it went straight through header and block header out.and footer etc.
if i do this div id=container mainbackground close div what z-index number is best to bring #mainbackground to rear.
#container {
width: 1024px;
margin-left: auto;
margin-right: auto;
text-align: left;
z-index: 2;
}
#mainbackground {
backgound:#FFFFFF;
z-index: 1;
}
Put your code in Codepen.io so we can get a better idea what you’re trying to do and what’s going wrong.
Do as @Senff said cause I am little confused as to what you want to do. I use sometimes different backgrounds for some divs if required and for this I develop classes like, example:
.bg-color-blue {background:#368;}
.bg-color-black{background:#000;}
You’re trying to give a div two IDs which is not correct.
I did it this way div id = “container” class=”backgroundwrapper”> Added z-index 2 to container and background with z-index 1 it worked some thing easy fix.
#container {
width: 1024px;
margin-left: auto;
margin-right: auto;
text-align: left;
z-index: 2
}
.backgroundwrapper {
width: 1024px;
margin-left: auto;
margin-right: auto;
text-align: left;
z-index: 1;
background: #FFFFFF;
}
As @JamesMD pointed out, z-index doesn’t work on elements positioned static by default. Set the position of one to relative and the other to absolute. Then set your z-index as you want.