阅读:3207回复:3
关于div(刚学 不要笑我)
<div>
<div id=left></div><div id=right></div> </div> 两个并排的div一个左 一个右 没有固定高度,怎么设置css才能始两个div高度一致啊? 也就是说低的始终和高的对齐. |
|
|
1楼#
发布于:2005-10-09 16:46
太谢谢了 记下了 :)
|
|
|
2楼#
发布于:2005-10-09 16:46
这么麻烦?
|
|
|
3楼#
发布于:2005-10-09 16:46
用CSS无法实现,可结合JS来自动调整。
代码如下: <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312"> <head> <title> new document </title> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <meta name="generator" content="editplus" /> <meta name="author" content="cnlei,枫岩,www.cnlei.net" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <link type="text/css" rel="stylesheet" href="" /> </head> <body> <div> <div id="left"></div><div id="right"></div> </div> <script type="text/javascript"> <!-- function AutoHeight(ObjA,ObjB){ var maxHth; var H1=document.getElementById(ObjA).scrollHeight; var H2=document.getElementById(ObjB).scrollHeight; maxHth=Math.max(H1,H2); document.getElementById(ObjA).style.height=maxHth+"px"; document.getElementById(ObjB).style.height=maxHth+"px"; } AutoHeight("left","right"); --> </script> </body> </html> |
|
|