日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
jquery實(shí)現(xiàn)導(dǎo)航欄

在當(dāng)今的移動(dòng)互聯(lián)網(wǎng)時(shí)代,手機(jī)導(dǎo)航已經(jīng)成為了網(wǎng)站和應(yīng)用程序的重要組成部分,jQuery作為一個(gè)輕量級(jí)的JavaScript庫(kù),可以幫助我們快速地實(shí)現(xiàn)手機(jī)導(dǎo)航功能,本文將詳細(xì)介紹如何使用jQuery編寫(xiě)手機(jī)導(dǎo)航。

成都創(chuàng)新互聯(lián)致力于互聯(lián)網(wǎng)網(wǎng)站建設(shè)與網(wǎng)站營(yíng)銷(xiāo),提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)站開(kāi)發(fā)、seo優(yōu)化、網(wǎng)站排名、互聯(lián)網(wǎng)營(yíng)銷(xiāo)、小程序設(shè)計(jì)、公眾號(hào)商城、等建站開(kāi)發(fā),成都創(chuàng)新互聯(lián)網(wǎng)站建設(shè)策劃專(zhuān)家,為不同類(lèi)型的客戶(hù)提供良好的互聯(lián)網(wǎng)應(yīng)用定制解決方案,幫助客戶(hù)在新的全球化互聯(lián)網(wǎng)環(huán)境中保持優(yōu)勢(shì)。

1、準(zhǔn)備工作

在使用jQuery編寫(xiě)手機(jī)導(dǎo)航之前,我們需要先引入jQuery庫(kù),可以通過(guò)以下方式引入:


為了方便操作DOM元素,我們還需要引入Bootstrap框架,通過(guò)以下方式引入:




2、創(chuàng)建導(dǎo)航欄

我們需要?jiǎng)?chuàng)建一個(gè)包含導(dǎo)航鏈接的導(dǎo)航欄,可以使用Bootstrap的navbar組件來(lái)實(shí)現(xiàn):


3、添加響應(yīng)式樣式

接下來(lái),我們需要為導(dǎo)航欄添加響應(yīng)式樣式,可以使用Bootstrap的媒體查詢(xún)(Media Queries)來(lái)實(shí)現(xiàn):

@media screen and (maxwidth: 768px) {
  .navbarheader {
    float: none;
  }
  .navbarleft, .navbarright {
    float: none !important;
  }
  .navbartoggle {
    display: block;
  }
  .navbarcollapse {
    bordertop: 1px solid transparent;
    boxshadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
  .navbarfixedtop {
    top: 0;
    borderwidth: 0 0 1px;
  }
  .navbarcollapse.collapse {
    display: none!important;
  }
  .navbarnav {
    float: none!important;
    margin: 7.5px 15px;
  }
  .navbarnav > li {
    float: none;
  }
  .navbarnav > li > a {
    paddingtop: 10px;
    paddingbottom: 10px;
  }
}

4、使用jQuery實(shí)現(xiàn)導(dǎo)航切換效果

為了使導(dǎo)航欄在小屏幕設(shè)備上更加美觀和易用,我們可以使用jQuery來(lái)實(shí)現(xiàn)導(dǎo)航切換效果,我們需要為每個(gè)導(dǎo)航鏈接添加一個(gè)類(lèi)名,例如dropdown


我們可以使用jQuery的hover方法來(lái)實(shí)現(xiàn)鼠標(biāo)懸停時(shí)的效果:

$(document).ready(function(){
  $(".dropdown").hover(            // When mouse enters...
    function() { $(this).toggleClass("open"); }, // Add "open" class to submenu links on parent menu item...              
    function() { $(this).removeClass("open"); } // ...and remove it when the mouse leaves.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            // Close one open menu item if the mouse leaves another open menu item                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // Remove "open" class from all submenu links inside the parent menu item                                                                                                                                                                                                                                                            // Remove the "open" class from any submenu links that are being opened (so they close) when the mouse leaves them                                                                                              });                                                      // Do NOT move code below this line       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         // This is only needed for the demo, so I've left it here for reference purposes:                  // Open one open menu item when the mouse leaves another open menu item                // Toggle "open" class between submenu links of the parent menu item on "mouseleave" event                                 // Toggle "open" class between submenu links of the parent menu item on "mouseenter" event                           // Add "open" class to parent menu item when its submenu links are clicked (currently only one submenu link can be open at a time)             // Add "open" class to parent menu item when its submenu links are clicked (currently only one submenu link can be open at a time)         // Add "open" class to parent menu items when their submenu links are clicked (currently only one parent menu item can be open at a time)          // Add "open" class to parent menu items when their submenu links are clicked (currently only one parent menu item can be open at a time)           // Add "open" class to parent menu items when their submenu links are clicked (currently only one parent menu item can be open at a time)           // Add "open" class to parent menu items when their submenu links are clicked (currently only one parent menu item can be open at a time)           // Add "open" class to parent menu items when their submenu links are clicked (currently only one parent menu item can be open at a time)           // Add "open" class to parent menu items when their submenu links are clicked (currently only one parent菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以打開(kāi)一次)          // Add "open"類(lèi)到父菜單項(xiàng)當(dāng)它們的子菜單鏈接被點(diǎn)擊時(shí)(目前只有一個(gè)父菜單項(xiàng)可以

新聞標(biāo)題:jquery實(shí)現(xiàn)導(dǎo)航欄
文章源于:http://www.dlmjj.cn/article/djsshcs.html