15.width,height

1.width,height

1.1获取窗口的高度与宽度(不包含工具条与滚动条)

var w=window.innerWidth;
var h=window.innerHeight;

1.2正文全文

// 正文全文宽
document.body.scrollWidth
// 正文全文高
document.body.scrollHeight

1.3可见区域(包含边线的宽)

相对于offsetParent 一直向上追溯到有定位的父级元素!

offsetLeft offsetTop
// 可见区域宽(包含边线的宽)
document.body.offsetWidth
// 可见区域高(包含边线的高)
document.body.offsetHeight

1.4可见区域(不包含边线的宽)

document.body.clientWidth
document.body.clientHeight

1.5被卷进去宽度,高度

document.body.scrollLeft
document.body.scrollTop

宽高

宽高

1.6在某个区域范围内

var left = Math.min(Math.max(x - 50,0),300);
var top = Math.min(Math.max(y - 50,0),200);
最小值,最大值

1.7offsetTop

https://blog.csdn.net/qq_42816270/article/details/138028929

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容