JSFiddle - React, Tailwind, and code Playground
by YangHax
HTML
<input type="button" id="animate" value="Animate!">
<div id="container">
<div class="flexed"></div>
<div class="flexed"></div>
<div id="width"></div>
</div>
CSS
#container {
width: 300px;
background: yellow;
display: -webkit-flex;
}
#container > div {
height: 50px;
margin: 5px;
}
#container > div.flexed {
-webkit-flex: 1;
background: green;
}
#container > div#width {
width: 50px;
background: orange;
-webkit-transition: width 1.0s ease-in-out;
}
JavaScript
// Flexbox CSS width shrink animation
document.getElementById('animate').addEventListener('click', function() {
document.getElementById('width').style.width = (Math.random()*200) + "px";
});