如何划分HTML表中两列之间的剩余水平空间?

时间:2022-03-02 20:28:11

I have an html table with say 5 columns. Three of the columns I want to have a fixed width (for example, td width=30,50,30). How would I divide the remaining horizontal space between the two remaining columns? I thought I would do it by just setting each of the "width" properties for those columns to "50%", but that didn't seem to work.

我有一个说5列的html表。我希望有三个列具有固定宽度(例如,td width = 30,50,30)。如何划分剩余两列之间的剩余水平空间?我想我会通过将这些列的每个“宽度”属性设置为“50%”来实现,但这似乎不起作用。

2 个解决方案

#1


1  

In my simple test, I didn't have to put anything and the default behavior was to split evenly. Of course, real content may push things around, so seeing your css and html would help.

在我的简单测试中,我没有放任何东西,默认行为是均匀分割。当然,真正的内容可能会推动一切,所以看到你的CSS和HTML会有所帮助。

<html>
    <head>
            <style type="text/css">
                    td{border:1px solid #000; padding:1px;}
            </style>
    </head>
<body>

        <table width="300px">
        <tr><td width="50px"></td><td width="30px"></td><td width="50px"></td><td></td><td></td></tr>
    </table>
</body>
</html>

#2


1  

Instead of having two columns with the space split, have one column, nest another table inside of it, and put two columns on the nested table each with a width of 50%.

不是有两个空格分割的列,而是有一列,在其中嵌套另一个表,并在嵌套表上放两列,每列宽度为50%。

#1


1  

In my simple test, I didn't have to put anything and the default behavior was to split evenly. Of course, real content may push things around, so seeing your css and html would help.

在我的简单测试中,我没有放任何东西,默认行为是均匀分割。当然,真正的内容可能会推动一切,所以看到你的CSS和HTML会有所帮助。

<html>
    <head>
            <style type="text/css">
                    td{border:1px solid #000; padding:1px;}
            </style>
    </head>
<body>

        <table width="300px">
        <tr><td width="50px"></td><td width="30px"></td><td width="50px"></td><td></td><td></td></tr>
    </table>
</body>
</html>

#2


1  

Instead of having two columns with the space split, have one column, nest another table inside of it, and put two columns on the nested table each with a width of 50%.

不是有两个空格分割的列,而是有一列,在其中嵌套另一个表,并在嵌套表上放两列,每列宽度为50%。