Not able to find the solution for this. Basically, what I am trying to achieve is to have an element with the position: sticky
appear with a scrollbar if there is more content then the browser height.
I don't want to use position: fixed
as it will add additional pain in the neck.
Here is the example of how I would expect it to work:
.placeholder {
height: 200vh;
width: 50%;
float: right;
}
.child {
position: fixed;
top: 0;
bottom: 0;
height: 100%;
overflow-y: auto;
}
<div class="parent">
<div class="placeholder"></div>
<div class="child">
some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br /> some long text
<br />
</div>
</div>
Here is example with the position: sticky
where the overflow
doesn't do anything:
.placeholder {
height: 200vh;
width: 50%;
float: right;
}
.child {
position: sticky;
top: 0;
bottom: 0;
height: 100%;
overflow-y: auto;
}
<div class="parent">
<div class="placeholder"></div>
<div class="child">
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
some long text <br />
</div>
</div>
Any explanation / solution appreciated.
Make sure to use Firefox when testing
position: sticky;
is supported. – Chubby