HTML Code

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />

    <link rel="stylesheet" href="style.css">

    <title>Document</title>

</head>

<body>

    <nav>

        <a href="javascript:void(0)" class="togglebtn" id="btn">

            <i class="fa fa-bars"></i>

        </a>

        <a href="">

            <span>NICT WEB</span>

        </a>

    </nav>

    <div class="wrapper">

        <div class="sidebar" id="side">

            <ul>

                <li>

                    <i class="fa fa-home"></i>

                    <a href="http://">Dashboard</a>

                </li>

                <li>

                    <i class="fa fa-home"></i>

                    <a href="http://">Dashboard</a>

                </li>

                <li>

                    <i class="fa fa-home"></i>

                    <a href="http://">Dashboard</a>

                </li>

                <li>

                    <i class="fa fa-home"></i>

                    <a href="http://">Dashboard</a>

                </li>

            </ul>

        </div>

        <div class="main" id="main">

            <div class="content">

                <h1>Content</h1>

            </div>

        </div>

    </div>

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

</body>

</html>

CSS Code

*{

    margin: 0;

    padding: 0;

    text-decoration: none;

    list-style: none;

    box-sizing: border-box;

}


nav{

   background-color: darkblue;

   padding: 25px;

}

nav a{

    color: white;

}


.wrapper .sidebar{

    padding: 25px;

    position: fixed;

    transform: translate(-100%);

    border: 2px solid red;

    width: 20%;

    height: 100%;


}


.wrapper .sidebar li{

    margin-bottom:15px ;

}

.wrapper .main_side{

    margin-left: 20%;

}


.wrapper .active{

    transform: translateX(0);

}

@media screen and (min-width:992px) {

    .wrapper{

        display: flex;

    }

    .wrapper .sidebar{

        position: fixed;

        transform: translate(0px);

    }

    .wrapper .main{

        margin-left: 20%;

        width: 80%;

    }

.togglebtn{

    display: none;

}

}

JAVASCRIPT Code

document.getElementById("btn").addEventListener("click",add);


function add(){

    var sidebar=document.getElementById("side");

    var main=document.getElementById("main");

    sidebar.classList.toggle("active");

    main.classList.toggle("main_side");

}

Comments

Popular posts from this blog

How to make simple bill maker by using python tkinter

Make a GST Calculator using HTML and JavaScript

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java