右侧锚点式固定滚动导航菜单

首先css解决一下ie6不支持position:fixed; 的缺陷。
css

css#menu { position: fixed; top: 100px; left: 50%; margin-left: 400px; width: 50px; } * html, * html body { background-image: url(about:blank); background-attachment: fixed; }* html #menu { position: absolute; bottom: auto; top: expression(100+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px'); }

【右侧锚点式固定滚动导航菜单】js:
javascript $(document).ready(function () { $(window).scroll(function () { var items = $("#content").find(".item"); var menu = $("#menu"); var top = $(document).scrollTop(); var currentId = ""; //滚动条现在所在位置的item id items.each(function () { var my = $(this); //m.offset().top代表每一个item的顶部位置 if (top > my.offset().top) { currentId = "#" + my.attr("id"); } else { return false; } }); var currentLink = menu.find(".current"); if (currentId && currentLink.attr("href") != currentId) { currentLink.removeClass("current"); menu.find("[href="https://www.it610.com/article/+ currentId +"]").addClass("current"); } }); });

    推荐阅读