日期:2014-05-16 浏览次数:20309 次
var top_height = document.getElementById("top").offsetHeight; var left_height = document.getElementById("left").offsetHeight; $(document).ready(function() { $(document).scroll(function() { var scroll_top = document.documentElement.scrollTop; var left_top = $("#left").offset().top; var m2_top = $("#m2").offset().top; if ((scroll_top > top_height) && (scroll_top + left_height < m2_top)) { $("#left").css({ "top": scroll_top }); } else { if (scroll_top < top_height) { $("#left").css({ "top": top_height + 20 }); } else { $("#left").css({ "top": m2_top - 10 - left_height }); } } }) })