表单元格宽度问题 [英] table cell width issue

查看:124
本文介绍了表单元格宽度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表有两行,我需要改变单元格宽度为

I have a table with 2 rows where i need varying cell width as

<body bgcolor="#14B3D9">
<table width="100%" border="1" bgcolor="#ffffff">
    <tr>
        <td width="25%">25</td>
        <td width="50%">50</td>
        <td width="25%">25</td>
    </tr>
    <tr>
        <td width="50%">50</td>
        <td width="30%">30</td>
        <td width="20%">20</td>
    </tr>
</table>
</body>

我无法获得指定的宽度,第二行也获得第一行的宽度。

I cannot get the width as specified the second row also gets the width of the first row.

推荐答案

可以使用一个表来执行此操作,您需要引入更多列,然后使用 colspan ,以便您可以获得所需的组合宽度

to do this with one table you need to introduce more columns and then get the column widths by using colspan so you can get the combined widths you require

,以使其在浏览器中正常工作,您可能需要使用< c $ c>< col>和< colgroup> 元素: http:// www.w3.org/TR/html401/struct/tables.html#h-11.2.4

to get this to work well across browser you will possibly need to use the <col> and <colgroup> elements : http://www.w3.org/TR/html401/struct/tables.html#h-11.2.4

<body bgcolor="#14B3D9">
<table width="100%" border="1" bgcolor="#ffffff">
<colgroup>
<col width="25%">
<col width="25%">
<col width="25%">
<col width="5%">
<col width="20%">
</colgroup>

    <tr>
        <td>25</td>
        <td colspan="2">50</td>
        <td colspan="2">25</td>     
    </tr>
    <tr>
        <td colspan="2">50</td>
        <td colspan="2">30</td>
        <td>20</td>
    </tr>
</table>
</body>

这篇关于表单元格宽度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆