JSFiddle - React, Tailwind, and code Playground
by Tan
HTML
<a href="#" onclick="pop();">POP</a>
<div id="pop" class="pop_closed">hello</div>
CSS
body {
display: grid;
height: 100vh;
place-items: center;
}
div {
background: #ff7a18;
height: 250px;
width: 250px;
}
.pop_closed {
display: none;
}
.pop_open {
animation-name: pop_open;
animation-timing-function: cubic-bezier(0.26, 0.53, 0.74, 1.48);
animation-duration: 0.3s;
}
@keyframes pop_open {
0% {
opacity: 0;
transform: scale(0.5, 0.5);
}
100% {
opacity: 1;
transform: scale(1, 1);
}
}
JavaScript
function pop() {
var pop = document.getElementById('pop');
if (pop.className == "pop_open") {pop.className = "pop_closed";}
else {pop.className = "pop_open";}
}