JSFiddle - React, Tailwind, and code Playground

by Adhik Bagul

HTML

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<!DOCTYPE html>
<html>
<head>
	<title>Mobile menu</title>
	<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
  <nav>
		<div class="toggle">
			<i class="fa fa-bars menu" aria-hidden="true"></i>
		</div>
		<ul>
			<li>Home</li>
			<li>About Us</li>
			<li>Services</li>
			<li>Blog</li>
			<li>Contact Us</li>
		</ul>
	</nav>
 </body>
</html>

CSS

body{
	margin: 0;
	padding: 0;
}
nav ul{
	list-style-type: none;
	padding: 0;
	margin:0;
	background-color: blue;
	font-size: 18px;
}
nav ul li{
	padding: 10px 16px;
	display: inline-block;
	color: #ffffff;
}
nav ul li:hover{
	background-color: #fff;
	color: #000;
}
nav .toggle{
	width: 100%;
	padding: 10px 20px;
	background-color: #001f44;
	color: #fff;
	text-align: right;
	box-sizing: border-box;
	display: none;
}



@media only screen and (max-width: 768px){
	nav .toggle{
		display: block;
	}

	nav ul{
		width: 100%;
		display: none;
	}
	
	nav ul li{
		display: block;
		text-align: center;
	}
	.active{
		display: block;
	}
}

JavaScript

$(document).ready(function(){
  $('.menu').click(function(){
    $('ul').toggleClass('active');
  })
})