JSFiddle - React, Tailwind, and code Playground
by volpeo
HTML
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Chrome Glitch</title>
</head>
<body>
<div id="container">
<div id="handle-container">
<div id="handle">X</div>
</div><div id="content">
<h2>Bla</h2>
<p>Bla bla bla bla bla bla bla</p>
</div><div id="menu">
<ul>
<li>Bla</li>
<li>Bla</li>
<li>Bla</li>
<li>Bla</li>
</ul>
</div>
</div>
</body>
</html>
CSS
body {
font-family: sans-serif;
color: white;
padding: 0;
margin: 0;
}
#container {
position: absolute;
right: 0;
height: 100%;
width: 100%;
text-align: right;
}
#content {
display: inline-block;
background: rgba(0, 0, 0, 0.6);
width: 0px;
height: 100%;
padding: 20px;
vertical-align: top;
text-align: left;
}
#menu {
display:inline-block;
background: rgba(0, 0, 0, 0.8);
width: 100px;
padding: 20px;
height: 100%;
vertical-align: top;
text-align: left;
}
#handle-container {
display: inline-block;
height: 100%;
}
#handle-container #handle {
background: black;
border-radius: 5px 5px 5px 5px;
color: white;
cursor: pointer;
padding: 5px 10px;
margin: 10px 10px 0 0;
position: relative;
}
#handle-container #handle:after {
border-color: transparent black;
border-style: solid;
border-width: 5px 0 5px 5px;
content: "";
display: block;
margin-top: -5px;
position: absolute;
right: -5px;
top: 50%;
width: 0;
}
JavaScript
$(document).ready(function(){
$('#content').css('width', '400px');
$('#handle').click(function(){
var visible = false;
$("#container>div:not('#handle-container')").each(function(){
if ($(this).is(':visible')) {
visible = true;
$(this).animate({width:'toggle'}, 350);
return false;
}
});
if (visible == false) {
$('#menu').animate({width:'toggle'}, 350);
}
});
});