日期:2014-05-17  浏览次数:20749 次

Firefox下table-layout:fixed无效问题
测试代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; UTF-8">
<title>任务进度新Gantt图(周-日)</title>

<style type="text/css">

.scrollColThead {
position: relative;
z-index: 2;
}

.scrollColThead th{
text-align: center ;
font-size: 12px;
border-bottom: 1px solid #4D7A9F;
border-right: 1px solid #4D7A9F;
}

</style>
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed">
<thead>
<tr class="scrollColThead" style="background-color:#A5BBCD;text-align:center;height:20px;">
<th style="background-color:#DDDDDD;text-align:center;width:20px;" title="2009-12-06">日</th>

<th style="width:20px;" title="2009-12-07">一</th>

<th style="width:20px;" title="2009-12-08">二</th>

<th style="width:20px;" title="2009-12-09">三</th>

<th style="width:20px;" title="2009-12-10">四</th>

<th style="width:20px;" title="2009-12-11">五</th>

<th style="background-color:#DDDDDD;text-align:center;width:20px;" title="2009-12-12">六</th>
</tr>
</thead>
</table>

</body>
</html>
   
  在IE6和Firefox3.6.8下测试发现整个表头行的宽度不相等,相差几个像素。当去除style="table-layout:fixed"时,在两个浏览器下行宽度是相等的!所以,推断是table-layout:fixed在Firefox下无效引起的,请问大家有没有其他的看法和解决方案,另, Firefox下有替代CSS expression方案 吗?请多指教 !谢谢!

------解决方案--------------------
请明确设置 width!
CSS 2.1规范:17.5.2.1 Fixed table layout

The table's width may be specified explicitly with the 'width' property. A value of 'auto' (for both 'display: table' and 'display: inline-table') means use the automatic table layout algorithm.
------解决方案--------------------
明确设置宽度,百分比,数字都可以