簡體   English   中英

在Yii引導程序中固定到頂部菜單

[英]Fixed To Top Menu in Yii Bootstrap

我需要對此進行簡單說明,我有一個菜單。 每當我向下滾動時,我都需要此菜單顯示在頁面的側面。 請幫我這樣做。

視圖:

<div id="fl_menu">
    <div class="label">MENU</div>
    <div class="menu">
        <a href="#" class="menu_item">An menu item</a>
        <a href="#" class="menu_item">A long menu item</a>
        <a href="#" class="menu_item">Item 3</a>
        <a href="#" class="menu_item">Another one</a>
        <a href="#" class="menu_item">A really, really long menu item</a>
        <a href="#" class="menu_item">Menu item 6</a>
        <a href="#" class="menu_item">And one more</a>
        <a href="#" class="menu_item">A tiny</a>
    </div>
</div>

JS代碼:

<script>  


//STICKY NAV
$(document).ready(function () {  
  var top = $('#fl_menu').offset().top - parseFloat($('#fl_menu').css('marginTop').replace(/auto/, 100));
  $(window).scroll(function (event) {
    // what the y position of the scroll is
    var y = $(this).scrollTop();

    // whether that's below the form
    if (y >= top) {
      // if so, ad the fixed class
      $('#fl_menu').addClass('fixed');
    } else {
      // otherwise remove it
      $('#fl_menu').removeClass('fixed');
    }
  });
});
</script>

提前致謝。

這與Yii完全無關。 無論如何,您都在尋找這個http://tutsme-webdesign.info/bootstrap-3-affix/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM