网页导航条滚动固定
function Head_menu(menu_container) { var _top = menu_container.offset().top; this.scroll_div = function () { var top = document.documentElement.scrollTop || document.body.scrollTop; if (top > _top) { menu_container.css({ 'position': 'fixed', 'top': '0', }); } else if (top < _top) { menu_container.css({ 'position': 'relative', 'top': '0', }); } } } var menu_container = $('#menu_fixed'); var head_menu = new Head_menu(menu_container); window.onscroll = function () { head_menu.scroll_div(); }