How to make a Left Sidebar in HTML CSS and JavaScript

Hey, developers welcome to Day 70 of our 90Days 90Projects challenge. And today, we are going to Create a Left Sidebar in HTML CSS, and JavaScript

So to run this code you just need to copy the HTML and CSS code and run it into your code Editor. 


Responsive sidebar menu HTML CSS, toggle sidebar using html and css, Open and close sidebar on button click javascript, Sidebar html CSS, Sidebar HTML CSS template, Simple sidebar HTML CSS



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> Toggle Sidebar </title>
    <link rel="stylesheet" href=""
        crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="style.css">


    <nav class="navbar">
        <h2> Geeks Help </h2>

        <div class="hamburger" id="hamburger">
            <div class="line one"></div>
            <div class="line two"></div>
            <div class="line three"></div>

        <ul class="lists" id="lists">
            <li><a href="#"> Home </a></li>
            <li><a href="#"> About Us </a></li>
            <li><a href="#"> Contact Us </a></li>
            <li><a href="#"> Services </a></li>
            <li><a href="#"> Privacy Policy </a></li>


    <main class="main-content">
        <h2> Welcome to Geeks Help </h2>

<script src="script.js"></script>


CSS Code


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
    transition: all 0.3s;

.navbar {
    width: 100%;
    position: sticky;
    top: 0;
    padding: 30px;
    height: 50px;
    background-color: #e65b00;
    border-bottom: 1px solid #e38e54;

.navbar h2 {
    position: absolute;
    top: 50%;
    color: #fff;
    left: 50%;
    transform: translate(-50%, -50%);

.hamburger {
    padding: 5px;
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
} .two {
    opacity: 0;
} .one {
    transform: rotate(45deg);
    top: 8px;
    position: absolute;
} .three {
    transform: rotate(-45deg);
    position: absolute;
    top: 8px;

.line {
    height: 3.2px;
    margin: 3px 0;
    width: 25px;
    background-color: #fff;

.lists {
    position: absolute;
    background-color: #e65b00;
    list-style: none;
    padding: 30px 50px 20px 20px;
    top: 50px;
    left: -180px;
    height: 100vh;
    z-index: 200;

.lists li {
    margin: 1px;
    border-bottom: 1px solid #ffffff56;
    width: 100%;

.lists li:hover {
    transform: translateX(10px);
} {
    left: 0;

.lists li a {
    text-decoration: none;
    color: #fff;
    line-height: 40px;

.main-content {
    display: grid;
    height: 1000px;

.main-content h2 {
    place-self: center;
    font-size: 2rem;



const hamburger = document.getElementById('hamburger');
const lines = document.querySelectorAll('.line');
const lists = document.getElementById('lists');

hamburger.addEventListener('click', function () {

Learn HTML- Learn Now

Learn CSS- Learn Now

Visit our 90Days, 90Projects Page- Visit Now

Post a Comment

* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad

Ads Section