js/jQuery中的寬高

來源:互聯網
上載者:User

標籤:htm   padding   隱藏   span   螢幕   scrollto   name   height   font   

一、和window有關的寬高

window.innerWidth:瀏覽器視窗寬度

window.innerHeight:瀏覽器視窗高度(不包括導航,工具列等的高度)

window.outerWidth:瀏覽器視窗寬度(很多時候===window.innerWidth)

window.outerHeight:瀏覽器視窗高度(包括導航,工具列等的高度)

window.screen.width:使用者裝置螢幕的寬度

window.screen.height:使用者裝置螢幕的高度

window.screen.availWidth:

window.screen.availHeight:

window.screenTop:瀏覽器距離螢幕頂部高度

window.screenLeft:瀏覽器距離螢幕左側寬度

 

二、client有關寬高

clientWidth、clientHeight: padding+content 如果有捲軸 再減去捲軸寬度/高度

clientTop:等於border-top的width

clientLeft:等於border-left的width

 

三、offset相關寬高

offsetHeight,

offsetWidth 等於border+padding+content;與內容是否超出原設定寬高無關,與是否有捲軸無關

offsetLeft:相對於定位父級(offsetParent)元素左側距離;offsetParent的margin-left+offsetParent的border-left寬度+當前元素的margin-left

offsetTop:相對於定位父級(offsetParent)元素左側距離;

 

四、與scroll相關的寬高

scrollLeft,被捲軸隱藏部分的寬度

scrollTop: 被捲軸隱藏部分的高度

scrollWidth:內容的全部實際寬度,當內容不超過可視地區的時候=clientWidth

scrollHeight:內容的全部實際高度,當內容不超過可視地區的時候clientHeight

 

五documentElement與body的關係

document(nodetype=9,nodeName=#docuemnt)——>documentElement(nodeType=1,nodeName=html)——>body(nodeType=1,nodeName=body) 

documentElement是body的父元素

 

js/jQuery中的寬高

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.