JSFiddle - React, Tailwind, and code Playground

by NOVUSIDEA

HTML

<div class="wrapper">
    <div class="side left"><h2>Left</h2></div>
    <div class="side right"><h2>Right</h2></div>
</div>

CSS

.wrapper {
    position: absolute;
    top: 1em;
    right: 1em;
    bottom: 1em;
    left: 1em;
    overflow: hidden;
    border: 1px solid #000;
    
}

.wrapper:hover .side {
    width: 20%;
    transition: all 0.5s;
}

.wrapper .side {
    position: absolute;
    width: 50%;
}

.wrapper .side h2 {
    position: absolute;
    height: 30px;
    line-height: 30px;
    top: 50%;
    margin-top: -15px;
}

.wrapper .side.left {
    transition: all 0.5s;
    background: white;
    color: black;
    top: 0;
    left: 0;
    bottom: 0;
}

.wrapper .side.left h2 {
    right: 20px;
}

.wrapper .side.right {
    transition: all 0.5s;
    background: black;
    color: white;
    top: 0;
    right: 0;
    bottom: 0;
}

.wrapper .side.right h2 {
    left: 20px;
}

.wrapper .side:hover {
    width: 80%;
}