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.
views:
47answers:
2
+2
A:
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%.
Eric Petroelje
2010-06-16 20:12:22
+1 nested tables, sweet.
Byron Whitlock
2010-06-16 20:12:47
@Byron - oh yeah, gotta love tables :)
Eric Petroelje
2010-06-16 20:13:33
That only works for neighbouring columns.
buti-oxa
2010-06-16 20:13:56
+1, Never would have thought of that.
zildjohn01
2010-06-16 20:19:41
Isn't there a more straight forward way to do it using the "WIDTH" property? This must be a pretty common thing to have to do.
GregH
2010-06-16 20:20:48
+1
A:
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.
<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>
BioBuckyBall
2010-06-16 20:34:54
Doing what I thought would not work does actually work. It was not working because I was overriding the default behavior elsewhere in my page through CSS. Once I fixed that, it did work by setting the remaining columns each to 50%
GregH
2010-06-16 22:26:22