开发者

HTML table layout question

If I have 3 columns for example:

<tr>
      <td></td>
      <td>Know the width</td>
      <td></td>
</tr>

In the 2nd column I know the width, and want this centered for example 777, and want the other 2 sides to take up what is left of the screen (in equal shares), how is this done?

This: simply doesn't work:

  <tr>
        <td width="*%" >&nbsp;</td>
        <td width="777"></td>
开发者_如何学C        <td width="*%"></td>
  </tr>


You can use the colgroup element:

<table>
    <colgroup>
        <col width="*">
        <col width="30">
        <col width="*">
    </colgroup>
    <tr>
          <td></td>
          <td>Know the width</td>
          <td></td>
    </tr>
</table>


Using floats would work better in this case. You could setup the middle float to have a fixed size, and the other two can be setup to fill the rest (I don't remember the exact css statements)


The following works with css2 browsers. The textaling is needed in the body for IE6.

<html>
    <head>
        <style>
        body{text-align:center;}
        #CenteredDiv{width:400px;margin:auto;background-color:silver;}
        </style>
    </head>
    <body>
        <div id="CenteredDiv">Centered Div</div>
    </body>
</html>

T

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜