<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
#outerDiv{
border:1px solid black;
width:200px;
height:150px;
overflow: auto;
}
#innerDiv{
width:2000px;
height:1500px;
}
</style>
</head>
<body>
<div id="outerDiv">
<div id="innerDiv">Scroll me right and left</div>
</div>
<p>Click on the button to display the css value (left, top, width, height) of outerDiv relative to the viewport.</p>
<button onclick="myFunction()">Click Me</button>
<p id="point"></p>
<script>
var x = document.getElementById("point");
var elem = document.getElementById("outerDiv");
function myFunction(){
var rect = elem.getBoundingClientRect();
var txt = "";
txt += "<br> Left : " + rect.left;
txt += "<br> Top : " + rect.top;
txt += "<br> Width : " + rect.width;
txt += "<br> Height : " + rect.height;
x.innerHTML += txt;
}
</script> </body>
</html>