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

php中世界最好的语言
Release: 2018-06-04 11:50:50
Original
2039 people have browsed it

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 screenPrecautionsWhat 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.

function size(){ document.write( "屏幕分辨率为:"+screen.width+"*"+screen.height +"
"+ "屏幕可用大小:"+screen.availWidth+"*"+screen.availHeight +"
"+ "网页可见区域宽:"+document.body.clientWidth +"
"+ "网页可见区域高:"+document.body.clientHeight +"
"+ "浏览器窗口宽:"+document.documentElement.clientWidth +"
"+ "浏览器窗口高:"+document.documentElement.clientHeight +"
"+ "html所有元素宽:"+document.documentElement.offsetWidth +"
"+ "html所有元素高:"+document.documentElement.offsetHeight +"
"+ "网页可见区域宽(包括边线的宽):"+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 ); }
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 theinner marginsize of the element content, excluding the border (actually includesunder 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) andThe distance between the upper left corner of thepositioned 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!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!