JSFiddle - React, Tailwind, and code Playground
by Victor
HTML
<div class="wrapper">
<div class="toggle">Cart</div>
<div class="cart">Cart</div>
</div>
CSS
/* normal */
.wrapper{
position:fixed;
width:300px;
height:100%;
background-color:orange;
top:0;
right:0;
margin-right:-250px;
/* Makes opening smoothly */
transition: margin-right ease 1s;
-moz-transition: margin-right ease 1s;
-webkit-transition: margin-right ease 1s;
-o-transition: margin-right ease 1s;
}
/* opened */
.wrapper.opened,
.wrapper:hover{
margin-right:0px;
}
.toggle {
position:relative;
display:block;
width:50px;
height:100%;
background-color:grey;
float:left;
text-align: center;
padding-top: 50%;
}
/* toggle style when wrapper is hovered */
.wrapper:hover .toggle{
background-color: #666;
color: white;
}
.wrapper:not(:hover) .toggle:before{
content:"Open ";
}
.wrapper:hover .toggle:before{
content:"Your ";
}
.cart {
position: relative;
width:250px;
height:100%;
background-color:red;
float:right;
}