Can't wrap your head around this seemingly simple issue. I get it, we've all been there.
Here's a snippet of HTML:
<div class="outer">
<div class="inner">
<!-- lots of text -->
</div>
<div class="inner-bottom">
This text should be inside the blue background
</div>
</div>
CSS stuff:
.outer {
height: 300px;
background: #99EEFF;
}
.inner {
height: 100%;
overflow: scroll;
}
.inner-bottom {
text-align: center
}
The main idea is to make sure both inner divs fit neatly within their parent container, with a clearly defined background color for clarity.
If height: 100%;
isn't specified on .inner
, things tend to go haywire, regardless of what you set the display
property to. In fact, certain display values can even mess up the height: 100%
rule.
All in all, solving this puzzle means making sure that .inner
's dimensions are controlled by .outer
, not the other way around. Ready to crack this? Let's do it!