Home Web Front-end H5 Tutorial How to operate the width and height attributes of the page, visual area, screen, etc.

How to operate the width and height attributes of the page, visual area, screen, etc.

Jun 04, 2018 am 11:50 AM
Screen page

This time I will show you how to operate the width and height properties of the page, visual area, and screen , and how to operate the width and height properties of the page, visual area, and screen Precautions What are they? Here are actual cases. Let’s take a look.

About some related width and height attributes of the page, visual area, screen, etc.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

function size(){

    document.write(

    "屏幕分辨率为:"+screen.width+"*"+screen.height

    +"<br />"+

    "屏幕可用大小:"+screen.availWidth+"*"+screen.availHeight

    +"<br />"+

    "网页可见区域宽:"+document.body.clientWidth

    +"<br />"+

    "网页可见区域高:"+document.body.clientHeight

    +"<br />"+

    "浏览器窗口宽:"+document.documentElement.clientWidth

    +"<br />"+

    "浏览器窗口高:"+document.documentElement.clientHeight

    +"<br />"+

    "html所有元素宽:"+document.documentElement.offsetWidth

    +"<br />"+

    "html所有元素高:"+document.documentElement.offsetHeight

    +"<br />"+

    "网页可见区域宽(包括边线的宽):"+document.body.offsetWidth 

    +"<br />"+

    "网页可见区域高(包括边线的宽):"+document.body.offsetHeight 

    +"<br />"+

    "网页正文全文宽:"+document.body.scrollWidth

    +"<br />"+

    "网页正文全文高:"+document.body.scrollHeight

    +"<br />"+

    "网页被卷去的高:"+document.body.scrollTop

    +"<br />"+

    "网页被卷去的左:"+document.body.scrollLeft

    +"<br />"+

    "网页正文部分上:"+window.screenTop

    +"<br />"+

    "网页正文部分左:"+window.screenLeft

    +"<br />"+

    "屏幕分辨率的高:"+window.screen.height

    +"<br />"+

    "屏幕分辨率的宽:"+window.screen.width

    +"<br />"+

    "屏幕可用工作区高度:"+window.screen.availHeight

    +"<br />"+

    "屏幕可用工作区宽度:"+window.screen.availWidth

    );

}

Copy after login
In addition, there are some attributes related to position and size of the html dom element, as follows

1. clientHeight and clientWidth are used to describe the inner size of the element, which refers to the inner margin size of the element content, excluding the border (actually includes under IE), outer edge Distance, scroll bar part

2. offsetHeight and offsetWidth are used to describe the outer size of the element, which refers to the inner margin border of the element content, excluding the outer margin and scroll bar part

3 . clientTop and clientLeft return the horizontal and vertical distance between the edge of the padding and the outer edge of the border, that is, the left and top border width

4. offsetTop and offsetLeft represent the upper left corner of the element (borderOuter edge) and The distance between the upper left corner of the positioned parent container (offsetParent object)

I believe you have mastered the method after reading the case in this article, please pay attention for more exciting things Other related articles on php Chinese website!

Recommended reading:

H5 Canvas use case detailed explanation

How to use the javascript Date Format method

offsetWidth

clientWidth

scrollWidth

offsetHeight

clientHeight

scrollHeight

offsetLeft

clientLeft

scrollLeft

offsetTop

clientTop

scrollTop

The above is the detailed content of How to operate the width and height attributes of the page, visual area, screen, etc.. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

How to copy a page in Word

Teach you how to turn off the automatic screen lock function in win10 Teach you how to turn off the automatic screen lock function in win10 Jan 08, 2024 am 11:49 AM

Teach you how to turn off the automatic screen lock function in win10

How to adjust the color when the screen turns black and white. Detailed introduction: How to exit black and white mode on your mobile phone. How to adjust the color when the screen turns black and white. Detailed introduction: How to exit black and white mode on your mobile phone. Mar 21, 2024 pm 01:12 PM

How to adjust the color when the screen turns black and white. Detailed introduction: How to exit black and white mode on your mobile phone.

iPhone screenshots not working: How to fix it iPhone screenshots not working: How to fix it May 03, 2024 pm 09:16 PM

iPhone screenshots not working: How to fix it

Does miniled screen hurt eyes? Does miniled screen hurt eyes? Feb 07, 2024 pm 03:48 PM

Does miniled screen hurt eyes?

Apple reveals iPhone 16 may have a larger display Apple reveals iPhone 16 may have a larger display Mar 22, 2024 pm 06:41 PM

Apple reveals iPhone 16 may have a larger display

How to deal with the black screen problem that occurs after increasing the screen resolution How to deal with the black screen problem that occurs after increasing the screen resolution Jan 15, 2024 pm 12:39 PM

How to deal with the black screen problem that occurs after increasing the screen resolution

How to close the 'Do not cover the top of the screen' Detailed explanation: How to close the 'Do not cover the top of the screen' message that appears frequently on your phone How to close the 'Do not cover the top of the screen' Detailed explanation: How to close the 'Do not cover the top of the screen' message that appears frequently on your phone Mar 03, 2024 pm 01:31 PM

How to close the 'Do not cover the top of the screen' Detailed explanation: How to close the 'Do not cover the top of the screen' message that appears frequently on your phone

See all articles