JSFiddle - React, Tailwind, and code Playground
HTML
<div id="box">
<div id="wiki_bar" class="in"></div>
<div id="vita" class="out"></div>
</div>
<button id="btn-switch" class="punch">The Buttton!</button>
CSS
#box {
position: relative;
/*define the you want*/
height: 60px;
}
#wiki_bar {
position: absolute;
height: 100%; width: 100%;
background: indianred;
-webkit-transition: 0.3s;
}
#wiki_bar.in {
/*waits 1 sec after #vita's
transition has finished*/
-webkit-transition-delay: 0.5s;
}
#wiki_bar.out {
-webkit-transition-delay: 0;
bottom: 100%;
}
#vita {
position: absolute;
height: 100%; width: 100%;
background: gold;
-webkit-transition: 0.4s;
}
#vita.in {
/*waits 1 sec after #wiki_bar's
transition has finished*/
-webkit-transition-delay: 0.4s;
}
#vita.out {
-webkit-transition-delay: 0s;
visibility: hidden;
opacity: 0;
}
/***************************************************
* BUTTON BY CHAD MAZZOLA @ http://hellohappy.org/ *
***************************************************/
body {
/*just so button is centered*/
text-align: center
}
.punch {
margin-top: 100px;
background: #4162a8;
border-top: 1px solid #38538c;
border-right: 1px solid #1f2d4d;
border-bottom: 1px solid #151e33;
border-left: 1px solid #1f2d4d;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
-moz-box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
box-shadow: inset 0 1px 10px 1px #5c8bee, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053, 0 8px 4px 1px #111111;
color: #fff;
font: bold 20px/1 "helvetica neue", helvetica, arial, sans-serif;
margin-bottom: 10px;
padding: 10px 0 12px 0;
text-shadow: 0px -1px 1px #1e2d4d;
width: 150px;
-webkit-background-clip: padding-box;
cursor: pointer;
}
.punch:hover {
-webkit-box-shadow: inset 0 0px 20px 1px #87adff, 0px 1px 0 #1d2c4d, 0 6px 0px #1f3053,...
JavaScript
var wiki = document.getElementById('wiki_bar'),
vita = document.getElementById('vita'),
btn_switch = document.getElementById('btn-switch'),
count = 0;
function doSwitch() {
if( count % 200 === 0 ) {
vita.setAttribute('class','in');
wiki.setAttribute('class', 'out');
} else {
vita.setAttribute('class', 'out');
wiki.setAttribute('class', 'in');
}
++count;
}
btn_switch.onclick = doSwitch;