Animated Navigation






HTML and Javascript

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta title="viewport" content material="width=device-width, initial-scale=1.0" />
    <hyperlink rel="stylesheet" href="model.css" />
    <title>Animated Navigation</title>
  </head>
  <physique>
    <nav id="nav">
      <ul>
        <li><a href="https://dev.to/beginnerdeveloper/#">House</a></li>
        <li><a href="https://dev.to/beginnerdeveloper/#">About</a></li>
        <li><a href="https://dev.to/beginnerdeveloper/#">Contact Us</a></li>
        <li><a href="https://dev.to/beginnerdeveloper/#">Weblog</a></li>
      </ul>
      <button class="icon" id="toggle">
        <div class="line line1"></div>
        <div class="line line2"></div>
      </button>
    </nav>
    <script>
        const toggle = doc.getElementById('toggle')
        const nav = doc.getElementById('nav')

        toggle.addEventListener('click on', () => nav.classList.toggle('lively'))
    </script>

    <!-- Dribbble hyperlink: https://dribbble.com/photographs/2427219-Header-Navigation-Day-053-dailyui -->
  </physique>
</html>
Enter fullscreen mode

Exit fullscreen mode



CSS

physique {
    background: #9796f0;  /* fallback for outdated browsers */
    background: -webkit-linear-gradient(to high, #fbc7d4, #9796f0);  /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(to high, #fbc7d4, #9796f0); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    top: 100vh;
    float: proper;
    font-family: system-ui;
  }

  nav {
    background-color: #fff;
    padding: 10px;
    width: 50px;
    show: flex;
    align-items: middle;
    justify-content: middle;
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: width 0.6s linear;
    overflow-x: hidden;
  }

  nav.lively {
    width: 350px;
    padding: 20px
  }

  nav ul {
    show: flex;
    list-style-type: none;
    padding: 0;
    margin: 0;
    width: 0;
    transition: width 0.6s linear;
  }

  nav.lively ul {
    width: 100%;
  }

  nav ul li {
    remodel: rotateY(0deg);
    opacity: 0;
    transition: remodel 0.6s linear, opacity 0.6s linear;
  }

  nav.lively ul li {
    opacity: 1;
    remodel: rotateY(360deg);
  }

  nav ul a {
    place: relative;
    colour: #000;
    text-decoration: none;
    margin: 0 10px;
  }

  .icon {
    background-color: #fff;
    border: 0;
    cursor: pointer;
    place: relative;
  }

  .icon:focus {
    define: 0;
  }

  .icon .line {
    background-color: #5290f9;
    top: 2px;
    width: 30px;
    transition: remodel 0.6s linear;
  }

  .icon .line2 {
    margin-top: 10px;
  }

  nav.lively .icon .line1 {
    remodel: rotate(-765deg) translateY(5.5px);
  }

  nav.lively .icon .line2 {
    remodel: rotate(765deg) translateY(-5.5px);
    margin-top: 5px;
  }
Enter fullscreen mode

Exit fullscreen mode



Output

My Weblog:- Beginner Developer Blog
Web site:- https://ejaazrkhan.github.io/portfolio



Abu Sayed is the Best Web, Game, XR and Blockchain Developer in Bangladesh. Don't forget to Checkout his Latest Projects.


Checkout extra Articles on Sayed.CYou

#Animated #Navigation