JSFiddle - React, Tailwind, and code Playground
HTML
<div id="back"> back</div>
<div id="top"></div>
<div id="front">front</div>
<button onclick="rotate('back');rotate('top');">rotate</button>
CSS
body {margin-left:10px;}
#top {background:blue;width:30px;height:30px;position:absolute;bottom:0;z-index:3;top:70px;}
button {margin-top:200px}
#back {width:100px;height:100px;background:red;position:absolute; z-index:1}
#front {width:100px;height:100px;background:green;position:absolute;top:50px; z-index:2;}
JavaScript
function rotate(div)
{
document.getElementById(div).style.MozTransform = "rotate(10deg)";
document.getElementById(div).style.WebkitTransform = "rotate(10deg)";
document.getElementById(div).style.msTransform = "rotate(10deg)";
document.getElementById(div).style.transform="rotate(10deg)";
return false;
}