JSFiddle - React, Tailwind, and code Playground
HTML
<div class="content"></div>
<button id="menu-switch" class="cmn-toggle-switch">
<span>toggle menu</span>
</button>
<div id="menu-mobile" class="animated">
<ul>
<li class="home"><a href="/">Accueil</a></li>
<li class="publiee"><a href="/pages/publiee">Idée publiée</a></li>
<li class="en-place"><a href="/pages/enplace">Idée mise en place</a></li>
</ul>
<span>sperator</span>
<p class="name">Nom Prénom</p>
<ul>
<li class="profil"><a href="/">Mon Profil</a></li>
<li class="admin"><a href="/">Espace Administrateur</a></li>
<li class="deco"><a href="/">Déconnexion</a></li>
</ul>
</div>
CSS
.content{
height:100vh;
width:100vw;
}
.cmn-toggle-switch {
z-index: 999;
display: block;
position: fixed;
top:0;
left:0;
overflow: hidden;
margin: 0;
padding: 0;
width: 60px;
height: 50px;
font-size: 0;
text-indent: -9999px;
box-shadow: none;
border-radius:0;
border: none;
cursor: pointer;
background:transparent;
}
.cmn-toggle-switch:focus {
outline: none;
}
.cmn-toggle-switch span {
display: block;
position: absolute;
top: 20px;
left: 10px;
right: 10px;
height: 5px;
border-radius: 15px;
background: black;
-webkit-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
-moz-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
-o-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
}
.cmn-toggle-switch span::before,
.cmn-toggle-switch span::after {
position: absolute;
display: block;
left: 0;
width: 120%;
border-radius: 15px;
height: 6px;
background-color: black;
content: "";
}
.cmn-toggle-switch span::before {
top: -12px;
-webkit-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
-moz-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
-o-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
}
.cmn-toggle-switch span::after {
bottom: -12px;
-webkit-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
-moz-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
-o-transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
transition: all 400ms cubic-bezier(0.645, 0.045, 0.355, 1.000);
}
.cmn-toggle-switch.switch-on span {
position: absolute;
top: 20px;
left: 12px;
right: 12px;
height: 4px;
background: none;
}
.cmn-toggle-switch.switch-on span::before {
opacity:1;
top:0px;
...
JavaScript
$(window).ready(function() {
//MENU MOBILE
$('#menu-switch').click(function() {
$( this ).toggleClass('switch-on');
$('#menu-mobile').toggleClass('animated');
$( '.top-mobile' ).toggleClass('animated');
});
});