JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="flex1"></div>
<div class="box box1"></div>
<div class="flex1 flex">
<div class="empty"></div>
<div class="box box2"></div>
<div class="box box3"></div>
</div>
</div>
CSS
html,body {
height: 100%;
margin: 0;
padding: 20px 50px;
}
.container {
transition: height 0.7s ease-in-out;
display: -webkit-flex;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 300px;
width: 300px;
margin: 0 auto;
background: tomato;
}
.empty {
height: 0;
}
.flex1 {
flex: 1;
-webkit-flex: 1;
}
.flex {
display: -webkit-flex;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.box {
margin: 0 auto;
background: yellow;
align-self: center;
}
.box.box1 {
width: 50px;
height: 50px;
}
.box.box2 {
width: 40px;
height: 40px;
}
.box.box3 {
width: 90%;
height: 30px;
}
JavaScript
var t = true;
setInterval(function() {
var container = document.querySelector('.container');
container.style.height = t ? "200px" : "300px";
t = !t;
}, 2000);