When I use float, childs pop out of parents.
I just put overflow:hidden
on the parent and the child pops back into its parent.
However, I can't do the same with an absolute div
and a relative div
.
.parent {
position: relative;
overflow: hidden;
}
.child {
position: absolute;
}
<div class="parent">
<div class="child">First</div>
<div class="child">Second</div>
</div>
The goal is to float 2 images one over another to create a slideshow, but still make the page respect the slideshow as an item.
Expected: "First" hovers above "Second" inside parent
Behavior: "First" and "second" are hidden, parent is 0px
in height
.
Upon removing overflow:hidden;
, they appear outside the parent.