JSFiddle - React, Tailwind, and code Playground

by manishie

HTML

<div class="someOtherDiv"></div>
<div class="theDiv">test</div>

CSS

.someOtherDiv {
    width:100px;
    background-color: green;
    height: 1000px;
}
.theDiv {
    width: 100px;
    height: 100px;
    background-color: red;
}

JavaScript

var top = $('.theDiv').offset().top; // the top of your div relative to the document
var div_height = $('.theDiv').height(); // the height of your div
window.scrollTo(0, top + div_height);