网页可见区域宽: 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 的方式来处理,则效果可能不同。

JS中关于clientWidth offsetWidth scrollWidth 等的含义的更多相关文章

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

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

  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. JS中关于clientWidth offsetWidth scrollWidth 等的区别

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

  6. JS中关于clientWidth offsetWidth srollWidth等的含义

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

  7. clientWidth,offsetWidth,scrollWidth区别

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

  8. clientWidth offsetWidth scrollWidth

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

  9. js中clientWidth, scrollWidth, innerWidth, outerWidth,offsetWidth的区别

    js中clientWidth, scrollWidth, innerWidth, outerWidth,offsetWidth的属性汇总,测试浏览器:ie7~ie11.chrome 和 firefox ...

随机推荐

  1. 关于mysql 查询内容不区分大小问题

    问题描述: select * from users where user_name ='user_01' 跟 select * from users where user_name ='uSer_01 ...

  2. 【转】ACM训练计划

    [转] POJ推荐50题以及ACM训练方案 -- : 转载自 wade_wang 最终编辑 000lzl POJ 推荐50题 第一类 动态规划(至少6题, 和 必做) 和 (可贪心) (稍难) 第二类 ...

  3. Uva 11354 LCA 倍增祖先

    题目链接:https://vjudge.net/contest/144221#problem/B 题意:找一条从 s 到 t  的路,使得瓶颈路最小. 点的数目是10^4,如果向之前的方案求 maxc ...

  4. [LeetCode_5] Longest Palindromic Substring

    LeetCode: 5. Longest Palindromic Substring class Solution { public: //动态规划算法 string longestPalindrom ...

  5. GridView数据绑定

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs& ...

  6. Kanzi编程基础3 - 图片读取与显示

    Kanzi开发的时候会遇到需要从外部读取图片的情况.Kanzi2.8版本和3.3版本读取方法稍有不同,我们先看看2.8版本的api. [2.8版本] 1)首先要从文件中读取一张图片 struct Kz ...

  7. Adobe Photoshop CC (32/64位) 绿色精简版

    32位版下载地址:http://pan.baidu.com/share/link?uk=33907222&shareid=3828486959 64位版下载地址:http://pan.baid ...

  8. 深入理解BFC和外边距合并(Margin Collapse)

    一.什么是BFC? 1.BFC的概念 BFC全称Block Formatting Context ,直译“块级格式化上下文”,也有译作“块级格式化范围”.它是 W3C CSS 2.1 规范中的一个概念 ...

  9. 零配置文件搭建SpringMVC实践纪录

    本篇记录使用纯java代码搭建SpringMVC工程的实践,只是一个demo.再开始之前先热身下,给出SpringMVC调用流程图,讲解的是一个http request请求到达SpringMVC框架后 ...

  10. linux限制ftp账户的访问路径

    1.建用户,命令行状态下,在root用户下: 运行命令:"useradd -d /home/test test" //增加用户test,并制定test用户的主目录为/home/te ...