Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
JS File
JavaScript
$(document).ready(function () {
    $(".icon").click(function () {
        $(".mobilenav").fadeToggle(500);
        $(".top-menu").toggleClass("top-animate");
        $(".mid-menu").toggleClass("mid-animate");
        $(".bottom-menu").toggleClass("bottom-animate");
        });
    });


Code

HTML
<li><a href="#home">HOME</a></li>
            <li><a href="#service">SERVICES</a></li>
            <li><a href="Portfoilo.aspx">PORTFOLIO</a></li>
            <li><a href="#">WHY US</a></li>
            <li><a href="#">CONTACT</a></li>
          </div>

          <a href="javascript:void(0)" class="icon">
             <div class="hamburger" style="margin-left:6px;">
               <div> <img style="width: 321px; height: 50px; margin-left: 511px;" src="Images/ar logo.jpg" /> </div>
               <div class="menui top-menu"></div>
               <div class="menui mid-menu"></div>
               <div class="menui bottom-menu"></div>
             </div>
          </a>



CSS file

CSS
* {
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-tap-highlight-color: transparent; /* For some Androids */
}

body {
  background-color: white;
  color: black;
}

h1 { color: white; }

.top-animate {
  background: #fff !important;
  top: 13px !important;
  -webkit-transform: rotate(45deg);
  /* Chrome, Safari, Opera */
  transform: rotate(45deg);
}

.mid-animate { opacity: 0; }

.bottom-animate {
  background: #fff !important;
  top: 13px !important;
  -webkit-transform: rotate(-225deg);
  /* Chrome, Safari, Opera */
  transform: rotate(-225deg);
}

.top-menu {
  top: 5px;
  width: 25px;
  height: 2px;
  border-radius: 10px;
  background-color: #F9A530;
}

.mid-menu {
  top: 13px;
  width: 25px;
  height: 2px;
  border-radius: 10px;
  background-color: #F9A530;
}

.bottom-menu {
  top: 21px;
  width: 25px;
  height: 2px;
  border-radius: 10px;
  background-color: #F9A530;
}

.menui {
  background: #FFFFFF;
  transition: 0.6s ease;
  transition-timing-function: cubic-bezier(.75, 0, .29, 1.01);
  margin-top: 18px;
  position: absolute;
}

.icon {
  z-index: 999;
  position: fixed;
  /*    background: rgba(0, 0, 0, 0.21);*/
  display: block;
  padding: 9px;
  height: 32px;
  width: 32px;
  margin: 0px;
  top: 0;
  left: 0;
}

.mobilenav {
  top: 47px !important;
  font-family: inherit;
  top: 0;
  left: 0;
  z-index: 999;
  display: none;
  position: fixed;
  width: 100%;
  height: 100%;
  background: #000000;
  opacity: 0.9;
}

.mobilenav li {
  list-style-type: none;
  text-align: center;
  padding: 10px;
}

.mobilenav li a {
  font-size: 250%;
  color: #fff;
  text-decoration: none;
  font-weight: 300;
  width: 100%;
}

.mobilenav li:first-child { margin-top: 60px; }


What I have tried:

Fade in and fade out not working properly on click function in navigation bar
Posted
Comments
Azziet 28-Jun-16 2:32am    
what is the exactly error you are getting?? edit you html & script in below fiddle

https://jsfiddle.net/y3c1qyhj/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900