SlickNav

JQuery 响应移动菜单插件。(Responsive Mobile Menu Plugin for jQuery.)

Github星跟蹤圖

JQuery 响应移动菜单插件。 SlickNav将默认使用jQuery的动画。 如果您希望使用Velocity.js进行动画制作,请务必在包含SlickNav之前将该库包含在代码中。

菜单显示无需任何其他配置,将显示原始和移动菜单。 建议使用媒体查询来隐藏原始菜单,并在适当时显示移动菜单。 Modernizr或类似的可以用于优雅降级。
例如:
.slicknav_menu {
display:none;}@media screen and (max-width: 40em) {
/* #menu is the original menu */ .js #menu { display:none; } .js .slicknav_menu {
display:block; }}

特性:

  • 多级菜单支持
  • 灵活、简单的标记
  • 跨浏览器兼容性
  • 键盘可访问
  • 没有JavaScript时优雅地降级
  • 创建ARIA兼容菜单
要求和浏览器支持
  • 需要jQuery 1.7+
测试浏览器:
  • Chrome
  • Firefox
  • Safari
  • Opera
  • IE7+
  • Android Browser
  • iOS Safari

概覽

名稱與所有者ComputerWolf/SlickNav
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
發布數12
最新版本名稱1.0.10 (發布於 )
第一版名稱1.0.0 (發布於 )
創建於2013-09-26 17:40:56
推送於2021-03-18 11:08:20
最后一次提交2021-01-12 16:06:23
星數0.9k
關注者數67
派生數316
提交數114
已啟用問題?
問題數172
打開的問題數73
拉請求數14
打開的拉請求數5
關閉的拉請求數8
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

SlickNav v1.0.10

Responsive Mobile Menu jQuery Plugin

Join the chat at https://gitter.im/ComputerWolf/SlickNav
jsDelivr Hits

SlickNav.io

Features

  • Multi-level menu support
  • Flexible, simple markup
  • Cross-browser compatibility
  • Keyboard Accessible
  • Degrades gracefully without JavaScript
  • Creates ARIA compliant menu

Usage

Include the CSS & JS

slicknav.css can be modified to fit website design

<link rel="stylesheet" href="SlickNav/dist/slicknav.min.css" />
<script src="SlickNav/dist/jquery.slicknav.min.js"></script>
<ul id="menu">
    <li><a href="#">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
    <li><a href="#">item 4</a></li>
</ul>

Initialize

<script>
    $(function(){
        $('#menu').slicknav();
    });
</script>

Options

'label' : 'MENU', // Label for menu button. Use an empty string for no label.
'duplicate': true, // If true, the mobile menu is a copy of the original.
'duration': true, // The duration of the sliding animation.
'easingOpen': 'swing', // Easing used for open animations.
'easingClose': 'swing' // Easing used for close animations.
'closedSymbol': '&#9658;', // Character after collapsed parents.
'openedSymbol': '&#9660;', // Character after expanded parents.
'prependTo': 'body', // Element, jQuery object, or jQuery selector string to prepend the mobile menu to.
'appendTo': '', // Element, jQuery object, or jQuery selector string to append the mobile menu to. Takes precedence over prependTo.
'parentTag': 'a', // Element type for parent menu items.
'closeOnClick': false, // Close menu when a link is clicked.
'allowParentLinks': false // Allow clickable links as parent elements.
'nestedParentLinks': true // If false, parent links will be separated from the sub-menu toggle.
'showChildren': false // Show children of parent links by default.
'removeIds': true // Remove IDs from all menu elements. Defaults to false if duplicate set to false.
'removeClasses': false // Remove classes from all menu elements.
'brand': '' // Add branding to menu bar.
'animations': 'jquery' // Animation library. Currently supports "jquery" and "velocity".

Callbacks

'init': function(){}, // Called after SlickNav creation
'beforeOpen': function(trigger){}, // Called before menu or sub-menu opened.
'beforeClose': function(trigger){} // Called before menu or sub-menu closed.
'afterOpen': function(trigger){} // Called after menu or sub-menu opened.
'afterClose': function(trigger){} // Called after menu or sub-menu closed.

Methods

$('.menu').slicknav('toggle'); // Method to toggle the menu
$('.menu').slicknav('open'); // Method to open the menu
$('.menu').slicknav('close'); // Method to close the menu

Animations

SlickNav will use jQuery for animations by default. If you wish to use Velocity.js for animating, be sure to include the library in your code before including SlickNav.

Without any additional configuration, both the original and mobile menus will be displayed. It is recommended to use media queries to hide the original menu and display the mobile menu when appropriate. Modernizr or similar can be used for graceful degradation.

For example:

.slicknav_menu {
    display:none;
}

@media screen and (max-width: 40em) {
    /* #menu is the original menu */
    .js #menu {
        display:none;
    }

    .js .slicknav_menu {
        display:block;
    }
}

More examples at SlickNav.io

Browser Support

  • Chrome
  • Firefox
  • Safari
  • Opera
  • IE7+
  • Android Browser
  • iOS Safari
去到頂部