1.首先下载 Responsive Nav插件。解压得到responsive-nav.css和responsive-nav.js文件,创建一个demo.html文件,并将三个文件放在一个目录中。
2.打开demo文件做如下修改:
<!doctype html>
<head>
<meta charset="utf-8">
<title>响应式导航</title>
<link rel="stylesheet" href="responsive-nav.css">
<script src="responsive-nav.js"></script>
</head>
<body>
<nav class="navlee">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<script>
var navigation = responsiveNav(".navlee");
</script>
</body>
</html>
3.打开js文件。将里面相对应代码修改为如下即可:
// Default options
this.options = {
animate: true, // Boolean: Use CSS3 transitions, true or false
transition: 284, // Integer: Speed of the transition, in milliseconds
label: "Menu", // String: Label for the navigation toggle
insert: "before", // String: Insert the toggle before or after the navigation
customToggle: "", // Selector: Specify the ID of a custom toggle
closeOnNavClick: false, // Boolean: Close the navigation when one of the links are clicked
openPos: "relative", // String: Position of the opened nav, relative or static
navClass: "navlee", // String: Default CSS class. If changed, you need to edit the CSS too!
navActiveClass: "js-nav-active", // String: Class that is added to <html> element when nav is active
jsClass: "js", // String: 'JS enabled' class which is added to <html> element
init: function(){}, // Function: Init callback
open: function(){}, // Function: Open callback
close: function(){} // Function: Close callback
};
4.打开css文件将里面的class名称修改为你demo里面nav的class即可!