首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

表格的兼容性有关问题,求指点~愁死人了

2013-03-16 
表格的兼容性问题,求指点~!愁死人了!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN ht

表格的兼容性问题,求指点~!愁死人了
<!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=utf-8" />
<title>无标题文档</title>
</head>

<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td rowspan="2" width="100" height="200" bgcolor="#990033">&nbsp;</td>
    <td height="10" bgcolor="#FFFF00">&nbsp;</td>
  </tr>
  <tr>
    <td height="100%" bgcolor="#CC0033"><p>sfsdfdfdsfdsf</p></td> 
  </tr>
</table>


</body>
</html>


在IE下, 第一行的第二个td设置了高为10,为什么显示不正常呢?
[解决办法]
关键点:
1.表格的height="100%"属性去掉。
2.第二个td添加样式属性:style="font-size:10px;line-height:10px;height:10px"
3.第三个td设置属性:height="190px"。
最简化的代码:


<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td rowspan="2" width="100px" height="200px" bgcolor="#990033">&nbsp;</td>
    <td style="font-size:10px;line-height:10px;height:10px" bgcolor="#FFFF00">&nbsp;</td>
  </tr>
  <tr> 
    <td height="190px" bgcolor="#CC0033"><p>sfsdfdfdsfdsf</p></td> 
  </tr>
</table>
</body>
</html>

热点排行