关于offset().top与scrollTop()
1.offset().top匹配元素相对于文档的偏移位置()
<body> <style type="text/css"> body { border:20px solid #CCC; margin:10px; padding:40px; background:#EEE; } #test { width:400px; height:200px; padding:40px; background:#F60; border:5px solid #888; } </style> <div id="test"></div> <script> var test = document.getElementById("test"); test.innerHTML = "<p>Browser:" + navigator.userAgent + "</p>" + "<p>offsetWidth:" + test.offsetWidth + "</p>" + "<p>offsetHeight:"+test.offsetHeight+"</p>"+ "<p>offsetLeft:"+test.offsetLeft+"</p>"+ "<p>offsetTop:"+test.offsetTop+"</p>"; </script> </body>
2.scrollTop()
匹配元素的滚动条的垂直位置(滚动条顶部,与滚动条长度无关)
勘破、放下、自在