JSFiddle - React, Tailwind, and code Playground

by Wentz Wu

HTML

<button>Go!</button>
<div id="wrapper">
    <div id="main">
        <div class="box"></div>
        <div class="box"></div>
        <div class="box"></div>
    </div>
</div>

CSS

#wrapper {
    position: relative;
    width: 300px;
    height: 300px;
}
#main {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: auto;
    z-index: 2;
    overflow: auto;
    overflow-x: hidden;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.box {
    width: 150px;
    height: 200px;
    margin: 5px;
    border: 1px solid red;
}

JavaScript

$("button").click(function () {
    $("#main").animate({
        scrollTop: parseInt($("#main").scrollTop()) + 50
    });
});