非池中之物 2013-10-07 09:14 采纳率: 0%
浏览 11904

html两个table的列不能对齐的问题

第一种写法能对齐:

<div>
<table class="tableStyle" sortMode="true" headFixMode="true" useMultColor="true" useClick="false"  useCheckBox="true">
<tr>
  <th style="width: 40px"></th>
  <th style="width: 80px">姓名</th>
  <th style="width: 40px">性别</th>
  <th style="width: 40px">年龄</th>
</tr>
</table>

</div>
<div id="scrollContent" >
<table class="tableStyle" headFixMode="true">
<tbody>
    <tr>
      <td width="40"><input type="checkbox" class="hand" name="items" value="1"/></td>

      <td width="80">
          姓名1
      </td>
      <td width="40">
            男
      </td>
      <td width="40"><span class="float_left">
        23
      </span> </td>
      </tbody></table></div>

但是第二种写法就不能对齐

    <div>
<table class="tableStyle" sortMode="true" headFixMode="true" useMultColor="true" useClick="false"  useCheckBox="true">
<tr>
  <th width="25%"></th>
  <th width="25%">姓名</th>
  <th width="25%">性别</th>
  <th width="25%">年龄</th>
</tr>
</table>

</div>
<div id="scrollContent" >
<table class="tableStyle" headFixMode="true">
<tbody>
    <tr>
      <td width="25%"><input type="checkbox" class="hand" name="items" value="1"/></td>

      <td width="25%">
          姓名1
      </td>
      <td width="25%">
            男
      </td>
      <td width="25%"><span class="float_left">
        23
      </span> </td>
      </tbody></table></div>

这是为什么?为什么用确定的数值px就能将2个table的列对齐,而用%的形式两个table的列就不能对齐

  • 写回答

1条回答

  • 赵王大人 2015-11-10 07:52
    关注

    那是因为第二个“姓名1”的width=“25%”,而第一个是80.。。。。。。。。
    13年的问题。。。。。

    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64