我这里有一个包含两个字段的表格,其中一个是 1 像素的高度,另一个是 100%。这个例子在谷歌浏览器中看起来很清楚。但它在 Mozilla 中不起作用。如何在 Mozilla 中修复?
<!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 profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
*{margin: 0; padding: 0;}
html, body{position: relative; width: 100%; height: 100%; overflow: hidden;}
table{height: 100%; width: 100%; position: relative;}
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" height="100%">
<tbody height="100%" >
<tr>
<td height="100%" valign="top">
<div style="overflow: auto; height: 100%">
sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />sdfsdf<br />a1
afasdasd sdfs sdv
</div>
</td>
</tr>
<tr>
<td height="1" valign="top">
test<br />test<br />test<br />test<br />test<br />
</td>
</tr>
</tbody>
</table>
</body>
</html>
最佳答案
我不确定 Mozilla 引擎如何解释 <td>
的 HTML 高度属性标记,但使用 CSS 来代替样式可能会获得更好的结果。您是否尝试过类似的方法:
在 HTML 中...
<td class="shortcell">
在你的样式 block 中......
td.shortcell {height: 1px; vertical-align: top;}
或内联...
<td style="height: 1px; vertical-align: top;">
更新:CSS height 属性仅适用于 block 级元素,因此您可以使用:
td.shortcell {height: 1px; vertical-align: top; display: block}
这会起作用,但会被反对。在表格单元格内放置一个 DIV 并为其应用高度可能更好。
HTML...
<td>
<div class="shortcell">
contents here
</div>
</td>
还有 CSS:
.shortcell {height: 1px;}
关于css - mozilla 中的表 <TR> 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5131792/