Skip to main content

 Basic Navbar Toggle





Basic Html Code source:


<html>

    <meta charset="utf-8">

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

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

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" referrerpolicy="no-referrer" />


    <title> slider</title>

<body>

    <section>

        <nav>

            <div class="logo">

                brand   logo

            </div>

            <div class="sidebar">

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

            <div class="side-bar">

            <ul> 

                <li><a href="#">Home</a></li>

                <li><a href="#">About</a></li>

                <li><a href="#">Service</a></li>

                <li><a href="#">Gallery</a></li>

                <li><a href="#">Contact</a></li>


            </ul>

        </div>

        </nav>

    </section>


    <section class="background-img-banner">

       

    </section>


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

</body>


</html>



2. Basic CSS code source:

*{

    box-sizing: border-box;

    padding: 0;

    margin: 0;

}


nav{

    background-color: #e2e2e2;

    height: 70px;

    width: 100%;

}

.logo{

    font-size: 36px;

    font-weight: 800;

    margin: 14px 21px;

    

    position:absolute;

    

}

ul{

    display: flex;

    float: right;

    margin: 21px 10px;

   

    

}

ul li{

    list-style: none;

    padding: 5px 15px;

    position: relative;

    margin: 0 5px;

    

  

}

ul li a{

    text-decoration: none;

    font-size: 20px;

    color: #032463;

    font-weight: 600;

}

ul li:hover{

    background-color: #032463;

    transition: .3s all;

    border-radius: 4px;

    

}

ul li:hover >a{

    color: #e2e2e2;

    transition: .3s all;

}


.background-img-banner{

    background-image: url(hero-bg.jpg);

    height: 100%;

    

    background-position: center;

    background-size: cover;


}

.background-img-banner::before{

    background-color: rgb(5 10 23 / 85%);

    position: absolute;

    content: "";

    width: 100%;

    height: 100%;

   

}


.sidebar i{

    padding: 15px;

    position: fixed;

    left: 85%;

    font-size: 28px;

    top: 10px;

    cursor: pointer;

    display: none;  

}




@media screen and (max-width: 676px) {

    .sidebar i{

        

        display: block;  

    }


    ul{

        display: inline;

        background: #071126;

        width: 100%;

        z-index: 9;

        position: absolute;

        top: 9%;

        margin: 0;

    }


    ul li{

        text-align: center;

        background-color: #e2e2e2;

        margin: 1px 0;

        padding: 9px 0;

    }

    .side-bar{

        display: none;

       transform: translate(100%);

       position:relative;

       top: 100%;

       z-index: 99;


    }

    .show-side-bar{

        

       display: block;

       

      

       transform: translate(0%);

       transition:all 0.5s linear;

      

    }

  }



3. basic javascript source code:

const bars= document.querySelector(".fa-bars");

const sidebar = document.querySelector(".side-bar");



bars.addEventListener("click", () => {

    

    sidebar.classList.toggle("show-side-bar")

});

4.output:



Comments

Popular posts from this blog

 HOW TO MAKE TIME COUNTDOWN BASIC NEEDS: HARDWARE 1. COMPUTER/ LAPTOP SOFTWARE 1. TEXT EDITOR EXAMPLE : VISUAL STUDIO, ATOM, SUBLIME TEXT, NOTEPAD++  ETC... HAVE A BASIC KNOWLEDGE 1. HTML5 2. CSS3 3. JAVASCRIPT LET'S SEE OUTPUT IN VIDEOS: HTML CODE: <!-- DEVELOP BY DELHI KA CODER --> < html >      < title > Count-down develop by delhikacoder </ title >      < meta   charset = "utf-8" >      < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      < link   rel = "stylesheet"   href = "style.css" />        < script   src = "javascript.js"   defer ></ script >      < body >          < section >              <...
 Make Responsive Mega Menu Bar  1. html 2. css 3. javascript  html and internal css code:   <! DOCTYPE   html >   < html   lang = "en" >   < head >      < meta   charset = "UTF-8" >       < meta   name = "viewport"   content = "width=device-width, initial-scale=1" >      < title > Responsive Mega menu </ title >         < link   href = "https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700i"   rel = "stylesheet" >      < link   rel = "stylesheet"   href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" >           < link   rel = "stylesheet"   href = "bootsnav.css" >         ...