JSFiddle - React, Tailwind, and code Playground
HTML
<div id="box">
hello
</div>
CSS
#box {
width:100px;
height:100px;
background:red;
opacity:1;
}
JavaScript
var box = document.querySelector('#box');
function addCssTransition(elem, speed) {
elem.style.cssText +=
';transition: all ' + speed + 's ease-in-out; ' +
'-moz-transition: all ' + speed + 's ease-in-out;' +
'-webkit-transition: all ' + speed + 's ease-in-out';
}
function fadeOut(elem, speed){
addCssTransition(elem, speed);
elem.style.opacity = 0;
elem.style.display = 'none';
}
fadeOut(box, 0.75);