JSFiddle - React, Tailwind, and code Playground

by Alexis López Espinoza

HTML

<div id = "foo"></div>

CSS

#foo{
    width: 25em;
    height: 15em;
    background: lightblue;
    border: .1em lightgreen solid;
    transition: .75s;
    margin: 0 auto;
}

JavaScript

var foo = document.getElementById("foo");
window.addEventListener("click", function (event){
    if (event.target != foo){
        foo.style.height = 0;
        setTimeout(function(){
            foo.style.display = "none";
        }, 750);
    }
}, false);