-1
<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>

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

4

1 回答 1

5

我不会使用 atable因为你没有显示表格数据。此外,发出position:absolute声音td真的很奇怪,甚至不确定它是否有效(所以它在一个浏览器中可能看起来不错,但在另一个浏览器中可能不行,特别是在 IE 7 及更低版本中,你可能想检查一下)

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

<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>

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

于 2012-06-14T20:41:46.467 回答