Firefox下tr行高不能为1px

  今天整理一个以前留下来的旧项目,该项目也必须兼容firefox.发现一个很奇怪的现象,tr里面所有的td的行高明明已经设置为 1px了.但在firefox下出来的效果就是4,5个px. 不管是用 style 还是直接用td 的 height都一样.但在IE中却是完全正确的.最后发现 table 加了 cellpadding=”3″ 这一个属性.原因找到就好办了,直接把行高为1px的行里的td全部都加上样式:

style="padding:0; height:1px;"

完整代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr bgcolor="#ffffff">
    <td height="20"><strong><font color="#000066">姓名</font></strong></td>
    <td><strong><font color="#000066">昵称</font></strong></td>
    <td><strong><font color="#000066">职位</font></strong></td>
  </tr>
  <tr>
    <td height="1" colspan="3" bgcolor="#000000" style="padding:0px">
      <div align="right"></div></td>
  </tr>
 
  <tr bgcolor="#FFFFFF">
    <td>小肥妹</td>
    <td>MM </td>
    <td>营业助理</td>
  </tr>
  <tr>
    <td style="padding:0;height:1px"></td>
    <td style="padding:0;height:1px"></td>
    <td style="padding:0;height:1px"></td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td>小胖哥</td>
    <td>GG </td>
    <td>经理</td>
  </tr>
  <tr>
    <td style="padding:0;height:1px"></td>
    <td style="padding:0;height:1px"></td>
    <td style="padding:0;height:1px"></td>
  </tr>
</table>
This entry was posted in CSS/XHTML and tagged , . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word