JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="item" style="background: red">a</div>
<div class="item" style="background: green">b</div>
<div class="item" style="background: blue">c</div>
<div class="item" style="background: purple">d</div>
</div>
CSS
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
}
.container {
flex-basis: auto;
display: flex;
flex-direction: column;
height: 100%;
}
.item {
flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
}
.collapse {
flex-grow: 0.001;
}
JavaScript
$(".item").click(function() {
$(".item").addClass("collapse");
$(this).removeClass("collapse");
});