如题,看代码:
- HTML code
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB2312"> </head> <body> <table align="center"> <tr> <td width="950px"> <div id="bg_div" style=" width:100%; height:313px; background-color:#666666;"> <div id="bg_image" width="100%" height="313px"> 背景内容 </div> </div> <div id="title_text_div" style="position:relative; left: 10px; top: -100px;background-color:#FF6666;">前景内容</div> </td> </tr> </table> </body> </html>
结果是:
tbody:956x337
tr:956x333
td:952x333
td的高度是两个div高度之和?即使两个div叠加了,高度也是算它们的和?
代码有问题请指正。
------解决方案--------------------
------解决方案--------------------
- HTML code
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <table align="center"> <tr> <td width="950px"> <div id="bg_div" style=" width:100%; height:313px; background-color:#666666;"> <div id="bg_image" style="width:100%;height:313px"> 背景内容 </div> </div> <div id="title_text_div" style="position:relative; left: 10px; top: -100px;background-color:#FF6666;">前景内容</div> <div id="demo" style="background-color:red; height:50px;"></div> <!--再加一个元素进去,就能清楚地看到上面这个容器的原占位符了--> </td> </tr> </table> </body> </html>