Online Tutorials Source Code

Dropdown Menu using Html CSS & Vanilla Javascript | User Account Navigation Project

Dropdown Menu using Html CSS & Vanilla Javascript | User Account Navigation Project. (Source Code).

Source Code:

HTML

Shortcuts simplify My Drive … 
In the coming weeks, items in more than one folder will be replaced by shortcuts. Access to files and folders won't change.Learn more
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Navigation Drawer Menu</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="navigation">
    <div class="userBx">
      <div class="imgBx">
        <img src="user.jpg">
      </div>
      <p class="username">Alina Smith</p>
    </div>
    <div class="menuToggle"></div>
    <ul class="menu">
      <li><a href="#"><ion-icon name="person-outline"></ion-icon> My Profile</a></li>
      <li><a href="#"><ion-icon name="chatbubble-outline"></ion-icon> Messages</a></li>
      <li><a href="#"><ion-icon name="notifications-outline"></ion-icon> Notification</a></li>
      <li><a href="#"><ion-icon name="settings-outline"></ion-icon> Settings</a></li>
      <li><a href="#"><ion-icon name="help-outline"></ion-icon> Help & Support</a></li>
      <li><a href="#"><ion-icon name="log-out-outline"></ion-icon> Logout</a></li>
    </ul>
  </div>
  <script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
  <script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>

  <script>
    const menuToggle = document.querySelector('.menuToggle');
    const navigation = document.querySelector('.navigation');
    menuToggle.onclick = function(){
      navigation.classList.toggle('active');
    }
  </script>
</body>
</html>

CSS

Shortcuts simplify My Drive … 
In the coming weeks, items in more than one folder will be replaced by shortcuts. Access to files and folders won't change.Learn more
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap');
*
{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Ubuntu', sans-serif;
}
body 
{
  min-height: 100vh;
  background: #6aa7d4;
  background: linear-gradient(45deg,#4E65FF ,#92EFFD);
}
.navigation 
{
  position: absolute;
  top: 20px;
  right: 20px;
  width: 120px;
  height: 60px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  transition: height 0.5s, width 0.5s;
  transition-delay: 0s,0.75s;
  overflow: hidden;
  box-shadow: 0 25px 35px rgba(0,0,0,0.1);
}
.navigation.active 
{
  width: 300px;
  height: 390px;
  transition: width 0.5s, height 0.5s;
  transition-delay: 0s,0.75s;
}
.navigation .menuToggle 
{
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.navigation .menuToggle::before  
{
  content: '';
  position: absolute;
  width: 32px;
  height: 2px;
  background: #555;
  transform: translateY(-10px);
  box-shadow: 0 10px #555;
  transition: 0.5s;
}
.navigation.active .menuToggle::before  
{
  transform: translateY(0px) rotate(45deg);
  box-shadow: 0 0 #555;
}
.navigation .menuToggle::after  
{
  content: '';
  position: absolute;
  width: 32px;
  height: 2px;
  background: #555;
  transform: translateY(10px);
  transition: 0.5s;
}
.navigation.active .menuToggle::after  
{
  transform: translateY(0px) rotate(-45deg);
}
.navigation .userBx 
{
  position: relative;
  width: 60px;
  height: 60px;
  transition: 0.5s;
  transition-delay: 0.5s;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.navigation.active .userBx 
{
  width: calc(100% - 60px);
  transition-delay: 0s;
}
.navigation .userBx .imgBx 
{
  position: relative;
  min-width: 60px;
  height: 60px;
  border: 10px solid #fff;
  background: #555;
  border-radius: 50%;
  overflow: hidden;
}
.navigation .userBx .imgBx img 
{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.navigation .userBx .username 
{
  white-space: nowrap;
  color: #555;
  font-size: 1.1em;
} 
.menu 
{
  position: absolute;
  width: 100%;
  height: calc(100% - 60px);
  margin-top: 60px;
  padding: 20px;
  border-top: 1px solid rgba(0,0,0,0.1);
}
.menu li 
{
  list-style: none;
}
.menu li a
{
  display: inline-block;
  text-decoration: none;
  margin: 20px 0;
  font-size: 1em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #555;
}
.menu li a:hover 
{
  color: #4E65FF;
}
.menu li a ion-icon 
{
  font-size: 1.5em;
}

Image:

Dropdown Menu using Html CSS & Vanilla Javascript | User Account Navigation Project

More Qeries: