当前位置: 代码迷 >> Web前端 >> scrollWidth offsetWidth offsetHeight offsetLeft .
  详细解决方案

scrollWidth offsetWidth offsetHeight offsetLeft .

热度:631   发布时间:2012-10-20 14:12:48.0
scrollWidth offsetWidth offsetHeight offsetLeft .....

?

function init(){
	
		 var a = document.getElementById("a");
		 a.innerHTML +="scrollWidth :"+ a.scrollWidth  +"<br/>"
		             + "scrollHeight :" + a.scrollHeight +"<br/>"
					 + "offsetWidth :" + a.offsetWidth +"<br/>"
					 + "offsetHeight :" + a.offsetHeight +"<br/>"
					 + "clientWidth :"+  a.clientWidth  +"<br/>"
					 + "clientHeight :"+  a.clientHeight  +"<br/>"
					 + "offsetLeft: "+a.offsetLeft+  "<br/>"
					 + "offsetTop: "+a.offsetTop
					  
 
	}

?

<div style="width:3600px ; height:600px; position:absolute; top:100px">
  <div style="width:300px ; height:200px; background:#CCCCCC; border: 1px ;padding:10px ; margin:3px;  position:absolute; top:2px; border:7px #000000 solid" id="a"  ></div>
 </div>

?IE

scrollWidth :20
scrollHeight :39
offsetWidth :300
offsetHeight :200
clientWidth :286
clientHeight :186
offsetLeft: 3
offsetTop: 5

?

IE中 border + clientWidth? = width

?

?

FF:

?

scrollWidth :334
scrollHeight :234
offsetWidth :334
offsetHeight :234
clientWidth :320
clientHeight :220
offsetLeft: 3
offsetTop: 5

?

FF 中 :

??? clientWidth? = width + padding

?

  相关解决方案