這篇文章主要介紹了css3和jquery如何實現(xiàn)可折疊導航菜單適合放在手機網(wǎng)頁的導航菜單,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
在荔浦等地區(qū),都構建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站設計、網(wǎng)站建設、外貿(mào)網(wǎng)站建設 網(wǎng)站設計制作定制制作,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,品牌網(wǎng)站制作,成都全網(wǎng)營銷推廣,外貿(mào)營銷網(wǎng)站建設,荔浦網(wǎng)站建設費用合理。效果圖如下:
這個實例由css3和依賴于jquery插件。下面是實現(xiàn)代碼
html代碼:
<nav class="nav" role="navigation" > <ul class="nav-items"> <li><a target=_blank href="http://www.w2bc.com">Home</a></li> <li><a target=_blank href="http://www.w2bc.com">About</a></li> <li><a target=_blank href="http://www.w2bc.com">Clients</a></li> <li><a target=_blank href="http://www.w2bc.com">Contact Us</a></li> </ul> </nav> <header > <button class="menu-button-target active" data-ic-class="button-trigger"> <span class="menu-button"></span> </button> Example Header </header> <section> <article> </article> <article> </article> <article> </article> <article> </article> <article> </article> </section>
css3代碼:
* { box-sizing: border-box; } body { font-family: "HelveticaNeue-Light" , "Helvetica Neue Light" , "Helvetica Neue" , Helvetica, Arial, "Lucida Grande" , sans-serif; font-weight: 300; } nav { position: fixed; -webkit-transform: translate3d(0, 0, 0); left: 0; transition: all 0.4s ease; width: 100%; background: #34495e; height: 0; overflow: hidden; transition-delay: 0.25s; } .active nav { transition-delay: 0s; } nav ul { width: 95%; margin: 0 auto; } nav ul li { padding: 5px; border-bottom: 1px solid white; } nav ul li:nth-child(1) a { transition-delay: 0.1s; } nav ul li:nth-child(2) a { transition-delay: 0.15s; } nav ul li:nth-child(3) a { transition-delay: 0.2s; } nav ul li:nth-child(4) a { transition-delay: 0.25s; } nav ul li:last-child { border: none; } nav ul li a { transition: all 0.2s cubic-bezier(0.455, 0.03, 0.515, 0.955); position: relative; display: block; text-decoration: none; color: white; font-size: 18px; padding: 10px; -webkit-transform: translate3d(100px, 0, 0); opacity: 0; } .active nav ul li a { -webkit-transform: translateX(0); opacity: 1; } header { transition: all 0.4s ease; -webkit-transform: translate3d(0, 0, 0); left: 0; width: 100%; position: fixed; background: #27ae60; color: white; padding: 20px; text-align: center; font-size: 20px; transition-delay: 0.25s; } .active header { transition-delay: .08s; } section { background: #f5f5f5; padding-top: 80px; } article { background: white; height: 500px; width: 95%; border-radius: 3px; margin: 0 auto 20px auto; border: 1px solid #e4e4e4; } .menu-button-target { background: transparent; border: none; outline: none; cursor: pointer; position: absolute; z-index: 200; left: 10px; height: 50px; top: 50%; margin-top: -23px; webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .menu-button-target.active .menu-button { transition: background .2s ease; background-color: transparent; } .menu-button-target.active .menu-button:before, .menu-button-target.active .menu-button:after { transition: top .3s ease, -webkit-transform .3s .2s ease; } .menu-button-target.active .menu-button:before { top: 0; -webkit-transform: rotate(45deg); } .menu-button-target.active .menu-button:after { top: 0; -webkit-transform: rotate(-45deg); } .menu-button { position: relative; top: 50%; left: 0; display: block; width: 40px; height: 4px; margin-top: -2px; background-color: white; border-radius: 10px; transition: background .2s .2s; } .menu-button:before, .menu-button:after { content: ""; display: block; position: absolute; width: 100%; height: 100%; left: 0; background-color: white; transition: top .3s .2s ease, -webkit-transform .3s ease; border-radius: 10px; -webkit-transform-origin: 50% 50%; } .menu-button:before { top: -10px; -webkit-transform: rotate(0deg); } .menu-button:after { top: 10px; -webkit-transform: rotate(0deg); }
js代碼:
var $menuTrigger = $('[data-ic-class="button-trigger"]'), $menuOverlay = $('[data-ic-class="overlay"]'), $menuItem = $('.menu-item'), activeClass = 'active', $nav = $('nav'), $navULHeight = $('.nav-items').outerHeight(), navOpen = false, $header = $('header'); var isTouch = false; if ($('html').hasClass('touch')) { isTouch = true; } function menuFunction() { $menuTrigger.toggleClass(activeClass); if (!navOpen) { $nav.height($navULHeight); navOpen = true; $('body').addClass('active'); $header.css('transform', 'translate3d(0, ' + $navULHeight + 'px, 0)'); } else { $nav.height(0); $header.css('transform', 'translate3d(0, 0, 0)'); navOpen = false; $('body').removeClass('active'); } } if (isTouch) { $menuTrigger.on('touchstart', function () { menuFunction(); }); } if (!isTouch) { $menuTrigger.on('click', function () { menuFunction(); }); }
感謝你能夠認真閱讀完這篇文章,希望小編分享的“css3和jquery如何實現(xiàn)可折疊導航菜單適合放在手機網(wǎng)頁的導航菜單”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設公司,,關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關知識等著你來學習!
新聞標題:css3和jquery如何實現(xiàn)可折疊導航菜單適合放在手機網(wǎng)頁的導航菜單-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://jinyejixie.com/article42/dhoihc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供建站公司、網(wǎng)站內(nèi)鏈、App開發(fā)、關鍵詞優(yōu)化、全網(wǎng)營銷推廣、自適應網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容