Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table columns 100% problem 1

Status
Not open for further replies.

Rekcor

Programmer
Feb 15, 2005
48
NL
I've got a simple problem but I can't find the solution. I hope someone can help me (I was surprised I couldnt find it in previous posts on this forum...)

What I want is:

a table (width 100%) with 3 columns, two with a fixed width (e.g. 50 and 40px), one with a variable width (which 'fills the gap' up to the 100% table width)

Code:
+---------+----------+---------------------+
|Column 1 | Column 2 | Column 3            |
+---------+----------+---------------------+

What I try is:

Code:
<table style="width:100%">
 <tr>
  <td style="width:50px">Column 1</td>
  <td style="width:40px">Column 2/td>
  <td style="width:100%">Column 3/td>
 </tr>
</table>

What I happens is:

the third column squeezes the other two to a width smaller than 50 and 40 px respectively. I get something like:

Code:
+---------------------------------------+
|Column|Column| Column 3                |
|1     |2     |                         |
+------+------+-------------------------+
 
This works for me in IE6 and FF:

Code:
<html>
<head>
</head>

<body>
	<table width="100%" border="1" cellspacing="0" style="table-layout:fixed;">
		<tr>
			<td width="50">Column 1</td>
			<td width="40">Column 2</td>
			<td>Column 3</td>
		</tr>
	</table>
</body>
</html>

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top