標籤: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中的寬高