Saturday, 2 January 2021

Navigation Bar with Hover Effect HTML CSS JS

Navigation Bar with Hover Effect HTML CSS JS


Download : Code

index.html

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css" type="text/css">
    <title>Navigation With Hover Effect</title>
  </head>
  <body>
  <div class="main">
    <div class="header">
      <input type="checkbox" id="btn">
      <a href="#">Menu</a>
      <a href="#">Products</a>
      <a href="#">About</a>
      <a href="#">Contact</a>
    </div>
  </div>
  <script type="text/javascript">
    const btn = document.querySelector("#btn");
    const header = document.querySelector(".header");
    btn.addEventListener("click",()=>{
      var htop = header.computedStyleMap().get('top').value;
      console.log(htop);
      if(htop=="-140"){
        header.style.top = "0px";
      }else{
        header.style.top = "-140px";
      }
    });
  </script>
  </body>
</html>

style.css

*{
    margin: 0;
    padding: 0;
}
body{
  background: black;
}
.header{
  margin: auto;
  width: 300px;
  height: 180px;
  background: rgb(10, 10, 10);
  position: relative;
  top: -140px;
  align-items: center;
  border-radius: 0 0 50px 50px;
  transition: all 0.5s;
}
.header::before,.header::after{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 0 0 50px 50px;
  background: linear-gradient(45deg,#ff0000,#00f0f0,#00ff00,#0000ff,#ff000069);
  z-index: -1;
  transform: scale(1.02);
  background-size: 500%;
  animation: anim 20s linear infinite;
}
@keyframes anim {
  0%, 100%{
    background-position: 0 0;
  }
  50%{
    background-position: 300% 0;
  }
}
.header::after{
  filter: blur(10px);
}
input{
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translate(-50%);
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}
input::before{
  content: '\f0c9';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  color: #f1f1f196;
}
a{
  margin: 20px;
  padding: 20px;
  color: rgb(95, 95, 95);
  position: absolute;
  font-weight: 700;
  font-family: cursive;
  text-decoration: none;
}
a:hover{
  color: #f1f1f196;
}
a:nth-child(3){
  left: 130px;
}
a:nth-child(5){
  top: 50px;
  left: 130px;
}
a:nth-child(4){
  top: 50px;
  left: 0px;
}


Download - Code

No comments:

Donate