A combination of position: sticky and a small change to your markup might work.
if you set .gotop
to sticky and load it at the very bottom of your story. You can then force it to be stuck to the bottom by using bottom: 0
I use float
here to push it to the right, which is pretty ugly. You can get rid if that if you use flex but I don’t know about the rest of your markup.
.story {
position: relative;
width: 50%;
margin: 0 auto;
height: 70vh;
background: #ddd;
overflow-y: auto;
}
.gotop {
position: -webkit-sticky;
position: sticky;
float: right;
margin-right: 10px;
bottom: 0;
padding: 14px 9px;
background: gold;
border-radius: 45% 45% 0 0;
cursor: pointer;
}
<div class='story'>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<p>Example</p>
<div class='gotop'>TOP</div>
</div>