JSFiddle - React, Tailwind, and code Playground
HTML
<div id="outer">
<div id="inner">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
</div>
</div>
<button onClick="toggleOuterHeight();">toggle outer div height</button>
CSS
#outer {
background-color: #1abc9c;
height: 400px;
position: relative;
overflow: auto;
}
#inner {
background-color: #16a085;
position: relative;
height: 250px;
width: 250px;
margin: auto;
top: 75px;
left: 0;
right: 0;
bottom: 0;
}
#inner ul {
margin: 0;
}
#inner ul li {
line-height: 25px;
}
JavaScript
toggleOuterHeight = function() {
if ($('#outer').css('height') == '400px') {
$('#outer').css('height','200px');
$('#inner').css('top','0');
} else {
$('#outer').css('height','400px');
$('#inner').css('top','75px');
}
}