js各種寬高的理解

來源:互聯網
上載者:User

標籤:滾動   blog   寬度   螢幕   top   flow   可視化   doc   screen   

1.window.innerHeight、window.outerHeight  視窗的外層的高度/內層高度

 

2.window.innerWidth/window.outerWidth  視窗的外層的寬度/內層寬度

 

3.window.screen包含有關使用者螢幕的資訊

  window.screen.width

  window.screen.height

  window.screen.availWidth(可視化的寬度)

  window.screen.availHeight(可視化的高度)

  window.screenTOP

  window.screenLeft

4.與document下面的client寬高

clientWidth/clientHeight:元素的可視部分寬度和高度,即padding+content

如果沒有捲軸,即為元素設定的寬高

有捲軸,本來寬高-捲軸的寬高

例如:

 1 body{ 2  3   border:20px solid red; 4  5   margin:10px ; 6  7   padding:40px; 8  9   background:blue;10 11   width:500px;12 13   height:350px;14 15   overflow:scroll;16 17 }

console.log(document.body.clientWight) //500+40*2=530
console.log(document.body.clientHeight) //350+40*2=430

 

 

 

5.offsetParent

6.document下面的scroll

 document.body.scrollWidth

document.body.scrollHeight

document.body.scrollLeft

document.body.scrollTop

 

 

 

 

js各種寬高的理解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.