首先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 ()