css:offset,scroll,client的用法
1. offsetWidth:width + padding + border
clientWidth:width + padding (不包含border)
scrollWidth:大小是内容的大小
2. event.ClientX:鼠标相对于客户窗口的横坐标
event.ClientY:鼠标相对于客户窗口的纵坐标
3.scrollTop: 被卷去的客户窗口的高
scrollLeft: 被卷去的客户窗口的宽
1 /* 获取被卷去的高:IE9+ 最新浏览器|| 非怪异模式,火狐 || 怪异模式,谷歌*/ 2 var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
1 /* 检测屏幕可视区域宽度:IE9+ 最新浏览器|| 非怪异模式,火狐 || 怪异模式,谷歌*/
2 var clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
4. window.scrollTo( x, y ):设置scrollLeft = x, scrollTop = y;