JSFiddle - React, Tailwind, and code Playground

by Simon Price

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="mySidenav" class="sidenav">
  <a href="javascript:void(0)" class="closebtn">&times;</a>
  <a href="#">About</a>
  <a href="#">Services</a>
  <a href="#">Clients</a>
  <a href="#">Contact</a>
</div>

<div id="slideOutNav">

  <span style="font-size:30px;cursor:pointer" id="open"><i class="far fa-comment"></i></span>
  <span style="font-size:30px;cursor:pointer" class="closebtn" id="close" hidden><i class="far fa-times-circle"></i></span>
</div>

CSS

body {
    font-family: "Lato", sans-serif;
    transition: background-color .5s;
}

.sidenav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: #111;
    overflow-x: hidden;
    transition: 0.5s;
    padding-top: 60px;
}

.sidenav a {
    padding: 8px 8px 8px 32px;
    text-decoration: none;
    font-size: 25px;
    color: #818181;
    display: block;
    transition: 0.3s;
}

.sidenav a:hover {
    color: #f1f1f1;
}

.sidenav .closebtn {
    position: absolute;
    top: 0;
    right: 25px;
    font-size: 36px;
    margin-left: 50px;
}

#slideOutNav {
    transition: margin-left .5s;
    padding: 16px;
    position: fixed;
    right: 0;
    top:50%;
}

@media screen and (max-height: 450px) {
  .sidenav {padding-top: 15px;}
  .sidenav a {font-size: 18px;}
}

JavaScript

$(document).ready(function(){

$("#open").click(function(){
    openNav();
})


$(".closebtn").click(function(){
    closeNav();
})
     
})

function openNav()
{
    document.getElementById("mySidenav").style.width = "500px";
    document.getElementById("slideOutNav").style.marginLeft = "250px";
    $("#open").hide()
    $("#close").show()
}

function closeNav()
{
    document.getElementById("mySidenav").style.width = "0px";
    document.getElementById("slideOutNav").style.marginLeft = "0px";
    $("#close").hide()
    $("#open").show()
}