区分js中各种宽高及位置

1. clientWidth、scrollWidth、offsetWidth

区分js中各种宽高及位置_第1张图片
  1. 浏览器的视口(不包括工具栏和滚动条)
    Internet Explorer、Chrome、Firefox、Opera 以及 Safari:
window.innerWidth、window.innerHeight

Internet Explorer 8、7、6、5:

document.documentElement.clientWidth、document.documentElement.clientHeight
或者document.body.clientWidth、document.body.clientHeight
  1. 屏幕宽度
screen.availWidth、screen.availHeight

4. event.clientX、event.clientY

事件相对于文档的坐标

5. event.offsetX、event.offsetY

事件相对于父容器的坐标

6.offsetLeft、offsetTop

相对于父元素的位置

6. scollLeft、scrollTop

可以设置滚动条距离初始点的位置,控制滚动条的滚动。

收藏网址
https://www.cnblogs.com/jiangxiaobo/p/6593584.html

你可能感兴趣的:(区分js中各种宽高及位置)