JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container1">
    <div id="container2">hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
        <br/>here
        <br/>hello
        <br/>I
        <br/>am
       ...

CSS

* {
    margin:0;
}
#container1 {
    height: 100%;
    width: 100%;
    border: 1px solid green;
    overflow: hidden;
    position: relative;
}
#container2 {
    position: absolute;
    top: 0px;
    bottom: 0px;
    left: 0px;
    right: 0px; /* exact value is given through JavaScript */
    border: 1px solid blue;
    overflow: auto;
}
html, body {
    height: 99%;
    border: 1px solid red;
    overflow:hidden;
}

JavaScript

var parent = document.getElementById('container1');
var child = document.getElementById('container2');
child.style.right = child.clientWidth - child.offsetWidth + "px";