JSFiddle - React, Tailwind, and code Playground

by kuyabiye

HTML

<div class="container">
    <div class="item" style="background: red">a</div>
    <div class="item" style="background: green"></div>
    <div class="item" style="background: blue"></div>
    <div class="item" style="background: purple"></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;
    transition: all 2s;
}

.collapse {
    flex-grow: 0.001;
}

JavaScript

$(".item").click(function() {
    $(".item").addClass("collapse");
    $(this).removeClass("collapse");    
});