2011-07-21 146 views
0

我有这样的表结构(我可以用Div来代替,如果可以解决起诉他们的问题)并且想要将左列的宽度设置为以像素为单位的固定大小,例如300px并且使右列自动宽度以保持从左列到浏览器边界的大小。我的解决方案在这种情况下不起作用。表列调整大小

<table> 
    <tr> 
     <td width="300"> 
      fixed size 
     </td> 
    </tr> 
    <tr> 
     <td width="100%"> 
      take free space 
     </td> 
    </tr> 
</table> 
+0

表在你的HTML只有一列.. – thirtydot

+0

我的意思是排..... – Tomas

+0

目前尚不清楚你以后。一个图像会有所帮助。 – thirtydot

回答

6

使用/起诉的DIV:

<div style="background-color: lime; float: left; width: 300px;">fixed size</div> 
<div style="background-color: cyan; margin-left: 300px;">take free space</div> 

Demo here

-1

通过属性或通过CSS,您的表格还应该具有width =“100%”。

0

尝试牵制你的表的左侧,并指定100%,然后让你的左边的列固定宽度,然后将右列固定在右侧。

<TABLE width="100%" height="100%" align="left" border="1"> 
     <TR> 
     <TD width="300px" height="100% align="left" valign="top"> 
     <p align="left">Get rid of the border by changing it to 0 after you get all of your placement down.</p> 
     </TD> 
     <!--other TDs if desired--> 
     <TD height="100%" align="right" valign="top"> 
      <p align="left">written stuff or images, etc.</p> 
     </TD> 
     </TR> 
    </TABLE>