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 ); }
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!