如何为可变单元格宽度设置固定表格边框宽度

时间:2013-04-02 00:29:08

标签: asp.net html width html-table radiobuttonlist

我有几个RadiobuttonLists,列表项的所有标签文本都有不同的宽度。 E.g。

RadiobuttonList#1

(o) this is a really long label         [textbox]

(o) this is another really long label   [textbox]

RadiobuttonList#2

(o) short label   [textbox]

(o) short         [textbox]

正如您所看到的,文本框自然地在每个radiobuttonlist集的最长标签的固定位置设置它们的位置。这就是我想要的。 (radiobuttonlist和文本框均位于<td>的{​​{1}}。)

但是,我在所有4个边上的每个桌子周围都有一个边框(所以想象一下上面我的例子中的浅蓝色背景是边框)。

我需要所有表格的宽度相同,即宽度为800px。

由于我不知道前2 <tables>的宽度,我如何确保它们加起来为800px?

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您应该能够使用简单的css规则来控制它。您可以将表格宽度设置为800px,然后设置输入字段的宽度,并让td填充到它们的最大宽度。看看这个小提琴的例子.. http://jsfiddle.net/JLF2n/

table{width:500px;background-color:#0af;border:2px solid #00f;padding:4px;}

td{border:2px solid #0f0;background-color:#afa;}
td+td{border:2px solid #ff0;background-color:#cc0;width:100px;}
input{width:100px;}

希望这会有所帮助