JSFiddle - React, Tailwind, and code Playground

by niks999

HTML

<div id="container">
    <img src="http://placehold.it/1000x1000" height="1000px" width="1000px" />
</div>

CSS

#container {
    overflow:auto;
    height:460px;
    width:320px;
    position:relative;
}

JavaScript

var element = document.getElementById('container'),
    scrollHeight = element.scrollHeight,
    scrollWidth = element.scrollWidth,
    clientHeight = element.clientHeight,
    clientWidth = element.clientWidth;

element.scrollTop = (scrollHeight - clientHeight) / 2;
element.scrollLeft = (scrollWidth - clientWidth) / 2;