开发者

Table should have real width

I have a table:

<table border="1px">
    <tr>
        <td style="width:200px">td1</td>
        <t开发者_JS百科d style="width:3200px">td2</td>
    </tr>
</table>

and the browser fits it in the current window, in it's width proportions I think. I would like the table to have it's real width, so that the window scrolls if necessary.


I don't know why the table behaves this way - upvotes from me for anybody who can explain in depth why the width on the tds gets overridden.

The easiest way around it would be giving the table element the composite width:

<table style="width: 3400px">

alternatively, putting a 3200px wide element into the td seems to work as well:

<td style="width:3200px"><div style="width: 3200px">&nbsp;</div></td>


TD widths are always interpreted as percentages in relation to the width of the entire table when the table does not overflow anymore. Tables do not overflow past the horizontal edge unless they have an explicit width set.

<table border="1px" width="3400px"> <!--The page will overflow if the table width is greater -->
  <tr>
   <td style="width:200px">td1</td>
   <td>td2</td> <!--The width of this cell will be whatever 3400-200 is. (i.e. 3200) -->
  </tr>
</table>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜