JSFiddle - React, Tailwind, and code Playground
HTML
<button id="down">down</button>
<div id="outer">
<div id="container">
<div id="inner">
<div id="animated">
</div>
</div>
</div>
<hr id="max" />
</div>
CSS
#outer {
position: relative;
width: 300px;
height: 300px;
background-color: #eee;
}
#container {
width: inherit;
height: inherit;
overflow-y: scroll;
overflow-x: hidden;
}
#inner {
width: 300px;
height: 2000px;
background-color: inherit;
}
#animated {
margin: 50px;
background-color: #33aa66;
width: 50px;
height: 50px;
}
#max {
position: absolute;
top: 200px;
background-color: #aa3333;
width: 100%;
height: 3px;
}
JavaScript
var new_margin;
$('#down').click(function() {
new_margin = 75 + parseInt($('#animated').css('margin-top'));
$("#animated").animate({marginTop: new_margin}, 1000);
});