我需要对此进行简单的澄清,我有一个菜单。每当我向下滚动时,我都需要将此菜单显示在页面的侧面。请帮我这样做。
查看:
<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>
提前致谢。