How to create Simple Mobile Toggle menu using css and Jquery | Sanwebcorner

How to create Simple Mobile Toggle menu using css and Jquery

Mobile toggle menu is simple way to display the links(menus) in mobile devices. Today i will explain about how to create the toggle menu and how to set this toggle menu to the mobile resolution. First you should set the two different navigation with same links then using media query set the normal menu to Min-width:760px set mobile menu to max-width:759px resolution

For example
use media query like below
@media only screen and (max-width: 759px) {
    .mobile-menu {
        display:block;
    }

.normal-menu {
        display:none;
    }
}

@media only screen and (min-width: 759px) {
    .mobile-menu {
        display:none;
    }

.normal-menu {
        display:block;
    }
}

So you will hide the normal menu and display the mobile menu in mobile resolution, The same process you will hide mobile menu and display the normal menu in desktop resolution.You can able to fix the menu like this. In this example i given only mobile menu, Here we have the demo page and full source code. You can download and use it. I hope this post is useful.

Source Code for Mobile Menu using Jquery:

<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Mobile toggle menu using jquery</title>
  
<style>
#toggle {
  display: block;
  width: 45px;
  height: 32px;
  margin: 30px auto 10px;
}

#toggle span:after,
#toggle span:before {
  content: "";
  position: absolute;
  left: 0;
  top: -9px;
}
#toggle span:after{
  top: 9px;
}
#toggle span {
  position: relative;
  display: block;
}

#toggle span,
#toggle span:after,
#toggle span:before {
  width: 100%;
  height: 5px;
  background-color: #851abc;
  transition: all 0.3s;
  backface-visibility: hidden;
  border-radius: 2px;
}

#toggle.on span {
  background-color: transparent;
}
#toggle.on span:before {
  transform: rotate(45deg) translate(5px, 5px);
}
#toggle.on span:after {
  transform: rotate(-45deg) translate(7px, -8px);
}
#toggle.on + #menu {
  opacity: 1;
  visibility: visible;
}

#menu {
  position: relative;
  color: #999;
  width: 290px;
  padding: 10px;
  margin: auto;
  font-family: "Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif;
  text-align: center;
  border-radius: 4px;
  background: white;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  opacity: 0;
  visibility: hidden;
  transition: opacity .4s;
  border: 1px solid #ccc;
}
#menu:after {
  position: absolute;
  top: -15px;
  left: 95px;
  content: "";
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-bottom: 20px solid white; 
  display:none;
}
#menu ul, li, li a {
  list-style: none;
  display: block;
  margin: 0;
  padding: 0;
}
#menu li a {
  padding: 5px;
  color: #888;
  text-decoration: none;
  transition: all .2s;
}
#menu li a:hover,
#menu li a:focus {
  background: #851abc;
  color: #fff;
}
    </style>

</head>
<body>
<a href="#menu" id="toggle"><span></span></a>
<div id="menu">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About us</a></li>
<li><a href="#gallery">Gallery</a></li>
<li><a href="#contact">Contact us</a></li>
</ul>
</div>
<script src="js/new-mob-menu.js"></script>
</body>
</html>

Post a Comment

Labels

360 degree view product image 3d rotate 3d text 3step-form Accordion menu ajax All Browsers Animated Background Gradient animation audio controller auto complete Best accordion menu bootstrap border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll create random number Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed email otp verification email verifier Embed eventlist Expanding Menu feedbck form flash news section close button full screen menu Google custom search Google Maps Google reCAPTCHA Google site search gradient hide menu Horizontal News ticker Hover Htm Html html dropdown html form html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript Jquery js Layered image effect on mouse hover lock & unlock page scroll marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form Multi-Step-form mysql News ticker on hover change text to image our team page password generator password strength checker Photoshop PHP populate html selectbox Popup image on click the link pure css Question type form random number generate Random password Redirect page Based on the select box while submit the form responsive responsive menu responsive popup box Responsive Vertical Time line design rotate image selectbox based on select box simple coming soon page simple countdown based on end date simple typing effect slider sliding tab sms otp login statistic counter on scroll switch tag shape team member Time picker toggle toggle view transparent button underline animation up down slide validation vertical fixed sidebar Webtips Youtube