固定到Yii Bootstrap中的顶部菜单

时间:2014-06-04 09:14:51

标签: javascript jquery css twitter-bootstrap yii

我需要对此进行简单的澄清,我有一个菜单。每当我向下滚动时,我都需要将此菜单显示在页面的侧面。请帮我这样做。

查看:

<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>

提前致谢。

1 个答案:

答案 0 :(得分:0)

这与Yii完全无关。无论如何你正在寻找这个 http://tutsme-webdesign.info/bootstrap-3-affix/

相关问题