Search
 
SCRIPT & CODE EXAMPLE
 

HTML

navbar with logo css

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Humburger Menu</title>
    <link rel="stylesheet" href="./style.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" integrity="sha256-46r060N2LrChLLb5zowXQ72/iKKNiw/lAmygmHExk/o=" crossorigin="anonymous" />
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        
        body {
            font-family: "Arial", sans-serif;
        }
        
        nav {
            background: #000;
            color: #fff;
            display: flex;
            justify-content: space-between;
        }
        
        nav .mainMenu {
            display: flex;
            list-style: none;
        }
        
        nav .mainMenu li a {
            display: inline-block;
            padding: 15px;
            text-decoration: none;
            text-transform: uppercase;
            color: #fff;
            font-size: 1.5rem;
        }
        
        nav .mainMenu li a:hover {
            background: rgb(255, 94, 0);
        }
        
        nav .openMenu {
            font-size: 2rem;
            margin: 20px;
            display: none;
            cursor: pointer;
        }
        
        nav .mainMenu .closeMenu,
        .icons i {
            font-size: 2rem;
            display: none;
            cursor: pointer;
        }
        
        .fa-facebook:hover {
            color: rgb(0, 110, 255);
        }
        
        .fa-twitter:hover {
            color: rgb(86, 154, 243);
        }
        
        .fa-instagram:hover {
            color: rgb(255, 0, 191);
        }
        
        .fa-github:hover {
            color: rgb(255, 123, 0);
        }
        
        nav .logo {
            margin: 6px;
            font-size: 25px;
            cursor: pointer;
        }
        
        @media (max-width: 800px) {
            nav .mainMenu {
                height: 100vh;
                position: fixed;
                top: 0;
                right: 0;
                left: 0;
                z-index: 10;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                background: #000;
                transition: top 1s ease;
                display: none;
            }
            nav .mainMenu .closeMenu {
                display: block;
                position: absolute;
                top: 20px;
                right: 20px;
            }
            nav .openMenu {
                display: block;
            }
            nav .mainMenu li a:hover {
                background: none;
                color: rgb(255, 123, 0);
                font-size: 1.6rem;
            }
            .icons i {
                display: inline-block;
                padding: 12px;
            }
        }
    </style>
</head>

<body>
    <nav>
        <div class="logo">
            <h1>Brand Name</h1>
        </div>
        <div class="openMenu"><i class="fa fa-bars"></i></div>
        <ul class="mainMenu">
            <li><a href="#">Home</a></li>
            <li><a href="#">Products</a></li>
            <li><a href="#">Contact</a></li>
            <li><a href="#">About</a></li>
            <div class="closeMenu"><i class="fa fa-times"></i></div>
            <span class="icons">
          <i class="fab fa-facebook"></i>
          <i class="fab fa-instagram"></i>
          <i class="fab fa-twitter"></i>
          <i class="fab fa-github"></i>
        </span>
        </ul>
    </nav>

    <script>
        // this is the script here
        const mainMenu = document.querySelector(".mainMenu");
        const closeMenu = document.querySelector(".closeMenu");
        const openMenu = document.querySelector(".openMenu");

        openMenu.addEventListener("click", show);
        closeMenu.addEventListener("click", close);

        function show() {
            mainMenu.style.display = "flex";
            mainMenu.style.top = "0";
        }

        function close() {
            mainMenu.style.top = "-100%";
        }
    </script>
</body>

</html>
Comment

PREVIOUS NEXT
Code Example
Html :: html to xml 
Html :: html bitcoin symbol 
Html :: what does ul mean html 
Html :: textarea ckeditor 
Html :: tailwind negative margin 
Html :: center text in html 
Html :: how to add a blinking text in html 
Html :: how to customize html audio tag 
Html :: how to jump line in html 
Html :: typo3 symlinks 
Html :: how to make a username and password in html 
Html :: how to get the input of a textbox in html 
Html :: make a div clickable 
Html :: bootstrap tablist 
Html :: html to text npm 
Html :: html text color tag 
Html :: how to add bar notation in html 
Html :: Tables in html 
Html :: html2pdf pagebreak option 
Html :: html svg 
Html :: html space code 
Html :: how to put text next to a checkbox in html 
Html :: which text is used to create text animations in html 
Html :: html article tag example 
Html :: html content in rectangle 
Html :: vertical line navigation bar 
Html :: bootstrap sweetalert 
Html :: reset button javascript onclick 
Html :: how to make check boxes in html 
Html :: bootstrap hide navbar 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =