JSFiddle - React, Tailwind, and code Playground

by darcyclarke

HTML

<div class="container">
    <div class="overlay"></div>
    <div class="modal">
        <div class="inner"></div>
    </div>
    <div class="content">
        <div class="inner"></div>
    </div>
</div>

CSS

*, *:before, *:after {
    box-sizing: border-box;
}

body {
    padding: 0;
    margin: 0;
    position: absolute;
    height: 100%;
    width: 100%;
}

.container {
    position: relative;
    width: 100%;
    height: 100%;
    border: 3px solid blue;
}

.content {
    position: absolute;
    width: 100%;
    min-height: 800px;
    border: 3px solid red;
    transition: all 0.3s;
}

.content .inner {
    width: 100%;
    min-height: 600px;
}

.active .content {
    max-height: 100%;
    overflow: hidden;
    background: transparent;
}

.overlay {
    position: absolute;
    background: rgba(0,0,0,0.5);
    top: 0;
    left: 0;
    width: 100%;
    max-height: 100%;
    z-index: -1;
    opacity: 0;
    transition: all 0.3s;
}

.overlay:after {
    content: '';
    display: block;
    position: relative;
    border: 3px solid orange;
    width: 100%;
    clear: both;
}

.active .overlay {
    max-height: auto;
    min-height: 100%;
    z-index: 9999;
    opacity: 1;
}

.modal {
    margin: 10% auto;
    width: 80%;
    background: white;
    opacity: 0;
    transform: translate3d(0, 50px, 0);
    transition: all 0.5s;
    border: 3px solid green;
}

.modal .inner {
    width: 100%;
    min-height: 900px;
}

.active .modal {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

JavaScript

var container = document.querySelector( '.container' );
container.addEventListener( 'click', function ( e ) {
    if ( this.classList.contains( 'active' ) ) { 
        this.classList.remove( 'active' );
    } else {
        this.classList.add( 'active' );   
    }
});