码迷,mamicode.com
首页 > 其他好文 > 详细

client与offset

时间:2015-10-22 18:52:33      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

<style>

  body{border:10px solid red}

</style>

console.log("document.body.offsetWidth:"+document.body.offsetWidth);
console.log("document.body.clientWidth:"+document.body.clientWidth);
console.log("document.body.scrollWidth:"+document.body.scrollWidth);

console.log("document.body.offsetHeight:"+document.body.offsetHeight);
console.log("document.body.clientHeight:"+document.body.clientHeight);
console.log("document.body.scrollHeight:"+document.body.scrollHeight);

console.log("document.body.offsetTop:"+document.body.offsetTop);
console.log("document.body.clientTop:"+document.body.clientTop);
console.log("document.body.scrollTop:"+document.body.scrollTop);

console.log("document.body.offsetLeft:"+document.body.offsetLeft);
console.log("document.body.clientLeft:"+document.body.clientLeft);
console.log("document.body.scrollLeft:"+document.body.scrollLeft);

 

运行结果:

document.body.offsetWidth:1903
document.body.clientWidth:1883
document.body.scrollWidth:1903

document.body.offsetHeight:2612
document.body.clientHeight:2592
document.body.scrollHeight:2612

document.body.offsetTop:0
document.body.clientTop:10
document.body.scrollTop:0

document.body.offsetLeft:0
document.body.clientLeft:10
document.body.scrollLeft:0

由以上结果可以看出,scroll=offset = client+border.

client与offset

标签:

原文地址:http://www.cnblogs.com/dzyBlog/p/4901761.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!