I have a flexbox and inside nested several divs
. In a deeper level is the main content (in yellow). I'd like to make it scrollable horizontally, but it only works if the divs
between .flexbox
and .content
aren't there. So if the divs are there, overflow-x: scroll
on the .content
doesn't behave as I'd expect.
Can anyone explain that? What would a possible solution look like to create a nested scrollable container in a flexbox?
.flexbox {
display: flex;
}
.content {
background-color: yellow;
height: 50px;
color: black;
overflow-x: scroll;
white-space: nowrap;
}
p {
display: inline-block;
}
<div class="flexbox">
<div> <!-- multiple nested divs like this one -->
<div class="content"> <!-- finally content -->
<p> I want to be able to scroll in here. </p>
<p> Not in the whole page </p>
<p> foo bar content </p>
<p> foo bar content </p>
<p> foo bar content </p>
<p> foo bar content </p>
<p> foo bar content </p>
<p> foo bar content </p>
</div>
</div>
</div>