最后一个单元格更改大小时表的位置问题

时间:2012-06-14 20:26:20

标签: html css

<table>                                        
    <tbody>                                        
        <tr style="height:30px">                              
            <td>Has a Menu and is goes to the extreme left</td>
            <td style="position: absolute; right: 238px;">this cell has a Checkout image and needs to be close to the next cell</td>
            <td style="vertical-align: top; padding-top: 0px; position: absolute; right: 12px;">has another menu and needs to go to the extreme right</td>
        </tr>
    </tbody>
</table>

第二个TD style="position: absolute; right: 238px;"需要能够根据最后一个带style="vertical-align: top; padding-top: 0px; position: absolute; right: 12px;"的TD来调整自身大小。 最后一个TD / Cell是好的,需要准确到位,这就是我必须设置位置的原因:绝对......但之前的TD需要在它之前。
如果我删除位置:在第二个TD上绝对,那么它向左移动,我不想要。如果我保持原样,那么当最后一个TD减小或增大时,如果影响第二个TD的屏幕位置 - 我需要第二个TD始终接近最后一个TD 你可以通过style="position: absolute; right: 238px;"重新定义/重构td的样式来帮助你吗?

1 个答案:

答案 0 :(得分:5)

我不会使用table,因为您没有显示表格数据。此外,给position:absolute td听起来真的很奇怪,不确定它是否有效(所以它在一个浏览器中可能看起来不错,但可能不在另一个浏览器中,特别是在IE 7和在下面,你可能想检查一下)

相反,使用<div>并定位它们应该更容易。有点像...

<div style='overflow:auto'>
  <div style='float:left'>Has a Menu and is goes to the extreme left</div>
  <div style='float:right'>has another menu and needs to go to the extreme right</div>
  <div style='float:right'>this cell has a Checkout image and needs to be close to the next cell</div>
</div>

作为一个例子,你需要玩当然的定位。注意你的第三个细胞是怎样的?在第二个之前。这不是一个错字,它是因为它们向右浮动,所以最右边的元素首先出现,下一个右浮动元素停在旁边等等。

相关问题