| <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>练习文档01</title> <style type="text/css"> <!-- body{ margin:0px;padding:0px; } .Div_top{ width:100%; background:#93beff; } .Div_bottom{ width:100%; background:#ff00fc; } .Div_Left{ position:absolute; width:200px; background:#ff6000; left:0px; } .Div_Right{ margin-left: 200px; background:#00c17b; } --> </style> <script> function SameH(leftDiv,rightDiv) { var a=document.getElementById(leftDiv); var b=document.getElementById(rightDiv); document.write(a.clientHeight+'--');
document.write(b.clientHeight+'--'); document.write(a.scrollHeight+'--'); document.write(b.scrollHeight+'--'); if (a.scrollHeight <
b.scrollHeight)
{ a.style.height= b.scrollHeight+"px"; } else { b.style.height= a.scrollHeight+"px"; } } </script> </head> <body> <div class="Div_top">这是顶部的div</div> <div id="Div1" class="Div_Left">11111<br>222222<br>33333333<br>444444444<br>555555555</div> <div id="Div2" class="Div_Right">22222<br>dsaf</div> <div class="Div_bottom">---------------------------------这是底部的DIV,在左中右 中DIV不等高的情况下会跑上去重叠了<br>------------------------------------ ----我现在想用一个JavaScript代码来令左右两半的Div等高<br><br> </div> <script> SameH("Div1","Div2"); </script> </body> |
浙公网安备 33010602011771号