<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        bootstrap自定義樣式之bootstrap實現側邊導航欄功能

        來源:懂視網 責編:小采 時間:2020-11-27 22:08:05
        文檔

        bootstrap自定義樣式之bootstrap實現側邊導航欄功能

        bootstrap自定義樣式之bootstrap實現側邊導航欄功能:bootstrap自帶的響應式導航欄是向下滑動的,有時滿足不了個性化的需求,需要做一個類似于android drawerLayout 側滑的菜單,這就是我要實現的bootstrap自定義側滑菜單,參考了很多官網的側滑,實現方法各有不同,優缺點也十分明顯,有的官網首頁為了僅僅實現
        推薦度:
        導讀bootstrap自定義樣式之bootstrap實現側邊導航欄功能:bootstrap自帶的響應式導航欄是向下滑動的,有時滿足不了個性化的需求,需要做一個類似于android drawerLayout 側滑的菜單,這就是我要實現的bootstrap自定義側滑菜單,參考了很多官網的側滑,實現方法各有不同,優缺點也十分明顯,有的官網首頁為了僅僅實現

        bootstrap自帶的響應式導航欄是向下滑動的,有時滿足不了個性化的需求,需要做一個類似于android drawerLayout 側滑的菜單,這就是我要實現的bootstrap自定義側滑菜單,參考了很多官網的側滑,實現方法各有不同,優缺點也十分明顯,有的官網首頁為了僅僅實現一個側滑的效果,用了owl.carousel滑屏的插件,個人覺得小題大做了。這個bootstrap側滑菜單更專業的名字叫做手機導航欄。我也比較這個名字,更符合bootstrap的特性。所以我這篇文章介紹的更容易的一種做法,新手更容易接受。

        bootstrap側邊導航欄實現原理

        1.側滑欄使用定位fixed
        2.使用bootstrap響應式使用工具類 visible-sm visible-xs hidden-xs hidden-sm等對不同屏幕適配
        3.側滑欄的側滑效果不使用jquery方法來實現,使用的是css3 transforms屬性進行div的移動,側滑的動畫效果使用的是css屬性transition
        4.缺點:使用兩套菜單,一套是pc端屏幕顯示的菜單,一套是移動端顯示的手機導航菜單,這個缺點比較明顯,生成無關的標簽,優點代碼少,簡單容易接受

        效果圖

        bootstrap側邊導航欄 

        這里寫圖片描述

        bootstrap側邊導航欄

        bootstrap導航欄布局
         <!--手機導航欄-->
         <div id="mobile-menu" class="mobile-nav visible-xs visible-sm">
         <ul>
         <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首頁</a></li>
         <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Java</a></li>
         <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >SVN</a></li>
         <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >iOS</a></li>
         </ul>
         </div>
         <!--pc導航欄-->
         <nav class="navbar-inverse visible-lg visible-md" role="navigation">
         <div class="container">
         <div class="navbar-header">
         <a class="navbar-brand" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >菜鳥教程</a>
         </div>
         <div>
         <ul class="nav navbar-nav">
         <li class="active"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >iOS</a></li>
         <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >SVN</a></li>
         <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="dropdown-toggle" data-toggle="dropdown">Java</a></li>
         </ul>
         </div>
         </div>
         </nav>
         <!--手機導航欄側滑-->
         <div class="nav-btn visible-xs visible-sm">
         <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="mobile-nav-taggle" id="mobile-nav-taggle">
         <span class="glyphicon glyphicon-align-justify"></span>
         </a>
         </div>

        一個導航欄的布局,用了兩個導航菜單,一個是pc端的,一個是手機端,利用bootstrap響應式使用工具類visible-xs visible-sm來實現pc端隱藏切換按鈕; visible-lg visible-md 實現了pc端顯示導航欄;visible-xs visible-sm實現手機端顯示手機導航欄。
        bootstrap響應式工具類詳見:https://www.runoob.com/bootstrap/bootstrap-responsive-utilities.html

        css實現布局和側滑效果(側滑的關鍵css3屬性transform、transition)

        代碼不多,僅僅10行 

         * {margin:0;padding:0;}
         #mobile-menu {position:fixed;top:0;left:0;width:220px;height:100%;background-color:#373737;z-index:9999;}
         a:hover ,a:focus{text-decoration:none}
         .mobile-nav ul li a {color:gray;display:block;padding:1em 5%; border-top:1px solid #4f4f4f;border-bottom:1px solid #292929;transition:all 0.2s ease-out;cursor:pointer;#mobile-menu {position:fixed;top:0;left:0;width:220px;height:100%;background-color:#373737;z-index:9999;transition:all 0.3s ease-in;}}
         .mobile-nav ul li a:hover {background-color: #23A1F6;color: #ffffff;}
         .show-nav {transform:translateX(0);}
         .hide-nav {transform:translateX(-220px);} /*側滑關鍵*/
         .mobile-nav-taggle {height:35px;line-height:35px;width:35px;background-color:#23A1F6;color:#ffffff;display:inline-block;text-align:center;cursor:pointer}
         .nav.avbar-inverse{position:relative;}
         .nav-btn {position:absolute;right:20px;top:20px;}

        要值得注意的是css3的兩個屬性:

        transform:旋轉div,支持元素2D或3D旋轉,屬性值translateX(X)就是在X軸上移動Xpx的距離

        http://www.w3school.com.cn/cssref/pr_transform.asp

        而側滑的動畫效果是使用transition屬性,設置屬性的過渡動畫的效果,語法

        transition: property duration timing-function delay;

        http://www.w3school.com.cn/cssref/pr_transition.asp

        單擊事件切換側滑

         $("#mobile-nav-taggle").click(function () {
         var mobileMenu = $("#mobile-menu");
         if (mobileMenu.hasClass("show-nav")) {
         setTimeout(function () {
         mobileMenu.addClass("hide-nav").removeClass("show-nav");
         }, 100)
         }
         else {
         setTimeout(function (){
         mobileMenu.addClass("show-nav").removeClass("hide-nav");
         }, 100)
         }
         })

        總結

        不推薦用兩個菜單導航欄,缺點很明顯,為了實現效果而已,不要介意,其實用一個菜單導航欄也是可以實現,試試media 完全可以實現。

        代碼下載地址: 點擊此處下載

        以上所述是小編給大家介紹的bootstrap自定義樣式之bootstrap實現側邊導航欄功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        bootstrap自定義樣式之bootstrap實現側邊導航欄功能

        bootstrap自定義樣式之bootstrap實現側邊導航欄功能:bootstrap自帶的響應式導航欄是向下滑動的,有時滿足不了個性化的需求,需要做一個類似于android drawerLayout 側滑的菜單,這就是我要實現的bootstrap自定義側滑菜單,參考了很多官網的側滑,實現方法各有不同,優缺點也十分明顯,有的官網首頁為了僅僅實現
        推薦度:
        標簽: 自定義 實現 樣式
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲最新视频在线观看| 久久精品国产亚洲精品| 亚洲综合小说久久另类区| a毛片免费全部在线播放**| 大胆亚洲人体视频| 一级黄色毛片免费看| 亚洲精品黄色视频在线观看免费资源| 国产AV无码专区亚洲AV琪琪 | 亚洲成aⅴ人片久青草影院按摩| 日韩免费精品视频| 欧洲 亚洲 国产图片综合| 女人18特级一级毛片免费视频| 极品色天使在线婷婷天堂亚洲| 国产一区在线观看免费| 一级毛片正片免费视频手机看| 亚洲精品乱码久久久久久蜜桃不卡| 97在线免费观看视频| 一区二区三区亚洲| 成年女人午夜毛片免费看| 色屁屁在线观看视频免费| 亚洲精品白浆高清久久久久久| 一级成人a毛片免费播放| 亚洲无砖砖区免费| 日韩在线天堂免费观看 | 亚洲伦理一区二区| 美女视频黄免费亚洲| 特级毛片免费观看视频| 亚洲VA中文字幕无码一二三区| ww4545四虎永久免费地址| 丰满亚洲大尺度无码无码专线| 亚洲人成网7777777国产| 我的小后妈韩剧在线看免费高清版 | 久久亚洲精品无码AV红樱桃| 在线免费观看a级片| 国产va免费观看| 亚洲成人一级电影| 亚洲精品高清在线| 久久精品免费一区二区| 日本高清免费中文在线看| 久久久亚洲欧洲日产国码是AV | 中文亚洲AV片在线观看不卡 |