Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create Hamburger Menu with HTML, CSS, and JavaScript
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hamburger Menu - HTML, CSS, & JS</title>
@media (max-width: 768px){
display: none;
display: block;
@media (min-width: 769px){
display: initial;
display: none;
<div class="tootle-menu" >
<h1 id="toggle-bar">
<ul class="mainMenu">
<li><a href="index.html">Home</a></li>
<li><a href="test.html">Test</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Portfolio</a></li>
function toggleMenu() {
let getMenu = document.querySelector(".mainMenu");
let getHamburger = document.querySelector("#toggle-bar");
getHamburger.addEventListener("click", toggleMenu);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment