JSFiddle - React, Tailwind, and code Playground
by Victor
HTML
<div class="wrapper">
<a href="#"><div class="toggle">Toggle</div></a>
<div class="cart">Cart</div>
</div>
CSS
.wrapper{
position:fixed;
width:300px;
height:100%;
background-color:orange;
top:0;
right:0;
margin-right:-250px;
}
.wrapper.opened{
margin-right:0px;
}
.toggle {
position:relative;
display:block;
width:50px;
height:100%;
background-color:grey;
float:left;
/* push text out of the Result overlay */
padding-top: 3em;
}
.cart {
position: relative;
width:250px;
height:100%;
background-color:red;
float:right;
}
JavaScript
var wrapper = document.getElementsByClassName('wrapper')[0];
var toggle = document.getElementsByClassName('toggle')[0];
window.onload=function(){
toggle.onclick=function(){
wrapper.classList.toggle('opened');
}
}