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()
匹配元素的滚动条的垂直位置(滚动条顶部,与滚动条长度无关)
原文地址:https://www.cnblogs.com/love-dream-88/p/11434292.html
时间: 2024-11-09 15:57:24