网页可见区域宽: document.body.clientWidth;
网页可见区域高: document.body.clientHeight;
网页可见区域宽: document.body.offsetWidth   (包括边线的宽);
网页可见区域高: document.body.offsetHeight  (包括边线的宽);
网页正文全文宽: document.body.scrollWidth;
网页正文全文高: document.body.scrollHeight;
网页被卷去的高: document.body.scrollTop;
网页被卷去的左: document.body.scrollLeft;
网页正文部分上: window.screenTop;
网页正文部分左: window.screenLeft;
屏幕分辨率的高: window.screen.height;
屏幕分辨率的宽: window.screen.width;
屏幕可用工作区高度: window.screen.availHeight;
屏幕可用工作区宽度:window.screen.availWidth;

1、offsetWidth width+padding+border)

当前对象的宽度。

style.width也是当前对象的宽度(width+padding+border)。

区别:1)style.width返回值除了数字外还带有单位px;

2)如对象的宽度设定值为百分比宽度,则无论页面变大还是变小,

style.width都返回此百分比,而offsetWidth则返回在不同页面中对象的宽度值而不是百分比值;

3)如果没有给 HTML 元素指定过 width样式,则 style.width 返回的是空字符串;

2、offsetHeight :(Height+padding+border)

当前对象的高度。

style.height也是当前对象的高度(height+padding+border)。

区别:1)style.height返回值除了数字外还带有单位px;

2)如对象的高度设定值为百分比高度,则无论页面变高还是变矮,

style.height都返回此百分比,而offsetHeight则返回在不同页面中对象的高度值而不是百分比值;

3)如果没有给 HTML 元素指定过 height样式,则 style.height返回的是空字符串;

3、offsetLeft :

当前对象到其上级层左边的距离。

不能对其进行赋值.设置对象到其上级层左边的距离请用style.left属性。

style.left当前对象到其上级层左边的距离。

区别:1)style.left返回值除了数字外还带有单位px;

2)如对象到其上级层左边的距离设定值为百分比,

style.left返回此百分比,而offsetLeft则返回到其上级层左边的距离的值;

3)如果没有给 HTML 元素指定过 left样式,则 style.left返回的是空字符串;

4、offsetTop :

当前对象到其上级层顶部边的距离。

不能对其进行赋值.设置对象到上级层顶部边的距离请用style.top属性。

style.top当前对象到其上级层顶部边的距离。

区别:1)style.top返回值除了数字外还带有单位px;

2)如对象到其上级层顶部边的距离设定值为百分比,

style.top返回此百分比,而offsetTop则返回到其上级顶部边的距离的值;

3)如果没有给 HTML 元素指定过 top样式,则 style.top返回的是空字符串;

注意:如果上级层为body,由于IE、FF对padding、margin的解释不一样所以要明确规定处理不是下列的区别就不成立了。

IE   1)如果Div的上级层是body,而div与body之间有个div,如body->div->divo;divo的offsetTop=div的padding+margin+boder;

2)如果Div的上级层是body,如body>divo;divo的offsetTop=div的padding+margin+boder;

这divo的offsetTop=divo的margin >body.padding则为divo的margin,否则为body.padding谁大是谁?

FF  上述两种情况:offsetTop=margin+padding ;

(IE与FF中的body默认padding为10)在IE6.0 FF3.6.13

5、scrollWidth:获取对象的滚动宽度 。

6、scrollHeight: 获取对象的滚动高度。

7、scrollLeft:设置或获取位于对象左边界和对象中目前可见内容的最左端之间的距离(width+padding为一体)

8、scrollTop:设置或获取位于对象最顶端和对象中可见内容的最顶端之间的距离;(height+padding为一体)

9、clientWidth: 获取对象可见内容的宽度,不包括滚动条,不包括边框;

10、clientHeight: 获取对象可见内容的高度,不包括滚动条,不包括边框;

11、clientLeft: 获取对象的border宽度

12、clientTop:获取对象的border高度

13、offsetParent :当前对象的上级层对象.

IE6.0、FF1.06+:
clientWidth = width + padding
clientHeight = height + padding
offsetWidth = width + padding + border
offsetHeight = height + padding + border

IE5.0/5.5:
clientWidth = width - border
clientHeight = height - border
offsetWidth = width
offsetHeight = height

以上属性测试的文档类型为:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

如果不写文档类型,浏览器就会按照 HTML 4.0 的方式来处理,则效果可能不同。

clientWidth offsetWidth scrollWidth的更多相关文章

  1. clientWidth,offsetWidth,scrollWidth区别

    <html> <head> <title>clientWidth,offsetWidth,scrollWidth区别</title> </head ...

  2. JS中关于clientWidth offsetWidth scrollWidth 的区别及意义

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  3. JS中关于clientWidth offsetWidth scrollWidth 等的含义

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  4. js中的clientWidth offsetWidth scrollWidth等的含义

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  5. JQuery中width和JS中JS中关于clientWidth offsetWidth scrollWidth 等的含义

    JQuery中: width()方法用于获得元素宽度: innerWidth()方法用于获得包括内边界(padding)的元素宽度: outerWidth()方法用于获得包括内边界(padding)和 ...

  6. JS中关于clientWidth offsetWidth scrollWidth 等的区别

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  7. JS中关于clientWidth offsetWidth scrollWidth 等的含义的详细介绍

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  8. HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth

    HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth scrollHeight: 获取对象的滚动高度. scrollLeft:设置或获取位于对 ...

  9. scrollWidth,clientWidth,offsetWidth的区别

      通过一个demo测试这三个属性的差别. 说明: scrollWidth:对象的实际内容的宽度,不包边线宽度,会随对象中内容超过可视区后而变大. clientWidth:对象内容的可视区的宽度,不包 ...

随机推荐

  1. JZOJ.5306【NOIP2017模拟8.18】棋盘游戏

    Description 这个游戏上在一个无限大的棋盘上, 棋盘上只有一颗棋子在位置(x,y)(x,y>=0)棋盘的左下角是(0,0)Amphetamine每次都是第一个移动棋子,然后Amphet ...

  2. 【BZOJ4818】[Sdoi2017]序列计数 DP+矩阵乘法

    [BZOJ4818][Sdoi2017]序列计数 Description Alice想要得到一个长度为n的序列,序列中的数都是不超过m的正整数,而且这n个数的和是p的倍数.Alice还希望 ,这n个数 ...

  3. Android遍历SqlLite cursor对象:

    //1. Cursor c =...; for(c.moveToFirst(); ! c.isAfterLast(); c.moveToNext()){ //c… } //2. Cursor curs ...

  4. 03.Curator深入使用

    1.Apache Curator简介     Curator提供了一套Java类库,可以更容易的使用ZooKeeper.ZooKeeper本身提供了Java Client的访问类,但是API太底层,不 ...

  5. Javascript-const 常量

    const 常量 常量是块级作用域,很像使用 let语句定义的变量.常量的值不能通过重新赋值来改变,并且不能重新声明. 此声明创建一个常量,其作用域可以是全局或本地声明的块. 与var变量不同,全局常 ...

  6. 英语知识(与字面意思 相反的) Corner office

    Corner office 角落办公室是一种身份 角落办公室,即处于公司最佳位置的高级办公室,通常指总裁或总经理办公室.喻某人在公司或单位里的最高职务或在社会上与众不同的身份地位. 这里的角落是指方形 ...

  7. Spoken English Practice (yesterday) (Look, I just wanted to apologize again for yesterday? It's fine, I know you didn't mean it. / when I say it, I mean it.)

    绿色:连读:                  红色:略读:               蓝色:浊化:               橙色:弱读     下划线_为浊化 口语蜕变(2017/7/12) ...

  8. Java Filter过滤xss注入非法参数的方法

    http://blog.csdn.NET/feng_an_qi/article/details/45666813 Java Filter过滤xss注入非法参数的方法 web.xml: <filt ...

  9. mysql 字符集研究

    一.创建一个测试数据库 及一个测试用的表.均使用默认的编码方式. show variables like 'char%': mysql> show variables like 'char%'; ...

  10. Systemd mysql,nginx,php启动配置文件

    systemctl的配置文件目录一般在 /usr/lib/systemd/system/ 或者/etc/systemd/system/ 需要注意的是,nginx与php运行用户必须是root,所以不需 ...