I am trying to create a scrollable div. I learnt that I can make it with overflow-y: scroll
, however, when I tried it, in my case it's overlapping its parent and it doesn't get scrollable.
Html:
<div id="parent">
<div id="child"></div>
</div>
Css:
#parent {
height: 100px;
width:300px;
background-color:red;
}
#child {
background-color: blue;
height: 150px;
width: 250px
}
In this example (that is also on bootply), I expected to keep the blue inside its parent and becomes a scrollable div; however instead it overlaped its parent and didn't get scrollable.
What am I doing wrong/missing?
add
overflow: auto
to parent