日期:2014-05-17 浏览次数:20781 次
<html id="_html"> <script> function op(id) { var off = document.getElementById(id); return id + " offsetParent : " + (!!off.offsetParent ? off.offsetParent : "null"); } window.onload = function() { document.getElementById("info").innerHTML = op("_body") + "</br>" + op("_html"); } </script> <body id="_body"> <div id="info"></div> </body> </html>
<html id="_html"> <script> function op(id) { var off = document.getElementById(id); return id + " offsetParent : " + (!!off.offsetParent ? off.offsetParent.id : "null"); } window.onload = function() { document.getElementById("info").innerHTML = op("_fixed"); } </script> <body id="_body"> <div id="_fixed" style="position:fixed;">fixed</div> <div id="info"></div> </body> </html>
<html id="_html"> <script> function op(id) { var off = document.getElementById(id); return id + " offsetParent : " + (!!off.offsetParent ? off.offsetParent.id : "null"); } window.onload = function() { document.getElementById("info").innerHTML = op("_normaldiv"); } </script> <body id="_body"> <div id="_positioned" style="position:relative;"> <div id="second"> <div id="_normaldiv"></div> </div> </div> <div id="info"></div> </body> </html>
<html id="_html"> <script> function op(id) { var off = document.getElementById(id); return id + " offsetParent : " + (!!off.offsetParent ? off.offsetParent.id : "null"); } window.onload = function() { document.getElementById("info").innerHTML = op("_normaldiv"); } </script> <body id="_body"> <div id="_pos