2010-04-14 113 views
1

我的網頁目前看起來是這樣的:收縮單元格(在絕對位置的ASP.NET表格中)以適合其內容?

<asp:Table runat="server" style="position: absolute; 
    left: 0%; top: 82%; right: 0%; bottom: 0%; width: 100%; height: 18%" 
    CellPadding="0" CellSpacing="0" GridLines="Both"> 
    <asp:TableRow> 
     <asp:TableCell> 
      Content1 
     </asp:TableCell> 

     <asp:TableCell Width="2.5%"> 
     </asp:TableCell> 

     <asp:TableCell > 
      Content2 
     </asp:TableCell> 
    </asp:TableRow> 
</asp:Table> 

http://img684.imageshack.us/img684/9677/tableu.png

但我需要它看起來像這樣:
http://img263.imageshack.us/img263/4508/table2k.png
「內容1」 是未知大小的,和表將不得不調整以適應它,但不會從「Content2」中分離出任何不必要的空間。我不能使用「display:table」,因爲它在IE7等不支持,所以我幾乎堅持使用常規的表格元素,除非在舊版瀏覽器中支持更好的東西。

有誰知道這是如何實現的?

回答

1

爲什麼不向Content2單元添加寬度?例如:

<asp:Table runat="server" style="position: absolute; 
    left: 0%; top: 82%; right: 0%; bottom: 0%; width: 100%; height: 18%" 
    CellPadding="0" CellSpacing="0" GridLines="Both"> 
    <asp:TableRow> 
     <asp:TableCell> 
      Content1 
     </asp:TableCell> 

     <asp:TableCell Width="2.5%"> 
     </asp:TableCell> 

     <asp:TableCell Width="97.5%"> 
      Content2 
     </asp:TableCell> 
    </asp:TableRow> 
</asp:Table> 
相關問題