I know, the title, sorry, but it makes sense. What I'm ultimately trying to achieve is create a container "unrelated" to the body that still respects its size constraints where I can push some messages.
<div id="big-container">
<div class="wrapper">
<div id="child">
</div>
</div>
</div>
In more detail, I'm trying to push child
, which is an absolute
div, inside the #big-container
which is also absolute
. To make my child
actually snap to big-container
, since they're both absolute
, I decided to introduce a wrapper classes that's relative. The styling is as such:
#big-container {
position: absolute;
z-index: 3; /* higher over everything else on the site */
}
.wrapper {
position: relative;
}
#child {
position: absolute;
}
Now, this works fine and dandy. Except...only on its own. See, thing is, I kinda wanna push these child
to the container only so that I don't actually polute other divs/the normal flow. They are, after all, completely detached from the flow. But if I do this, anything that is under #big-container
becomes unusable because, well, it's hidden by it. Let's see it in action:
body {
width: 960px;
height: 100%;
}
#big-container {
display: block;
height: 100%;
width: 100%;
top: 0;
left: 0;
position: absolute;
}
.wrapper {
display: block;
width: 100%;
height: inherit;
position: relative;
padding: 12px;
}
#child {
background-color: red;
border: 1px solid black;
color: white;
position: absolute;
}
<body>
<h3> This is some content from the site!</h3>
<p>...and some more!</p>
<div id="big-container">
<div class="wrapper">
<div id="child">
I am the child! Try to select anything below me, see if it works.
</div>
</div>
</div>
</body>
What am I missing here? I feel as if the markup itself is wrong. All I'm trying to do is be considerate of others and simply contain my messages to a single space.