# fixed ratio column width

Page 1 of 1

## 4 Replies - 946 Views - Last Post: 10 October 2013 - 11:56 AM

### #1 Dormilich

• 痛覚残留

Reputation: 3541
• Posts: 10,226
• Joined: 08-June 10

# fixed ratio column width

Posted 10 October 2013 - 05:58 AM

Hi there,

I have a table with several columns having a fixed width and two columns of variable width (see below). how can I arrange it that the two columns take up an equal width (i.e. distribute the remaining width equally among them).
I already tried width="*", percentages don’t work either (unless I give % to all columns, which I don’t want).

example table
```      <table class="data-section mitte eigenschaften">
<caption>Fernkampf</caption>
<colgroup>
<col/>
<col style="width: 2em;"/>
<col style="width: 5em;"/>
<col style="width: 5em;"/>
<col style="width: 5em;"/>
<col/>
<col style="width: 2em;"/>
<col style="width: 5em;"/>
<col style="width: 5em;"/>
<col style="width: 5em;"/>
</colgroup>
<tr>
<th>Talent</th>
<th></th>
<th>AT</th>
<th>PA</th>
<th>TaW</th>
<th>Talent</th>
<th></th>
<th>AT</th>
<th>PA</th>
<th>TaW</th>
</tr>
<tbody>
<tr>
<td>C</td>
<td>24</td>
<td></td>
<td>16</td>
<td>D</td>
<td>8</td>
<td></td>
<td>0</td>
</tr>
</tbody>
</table>

```

Is This A Good Question/Topic? 0

## Replies To: fixed ratio column width

• MSX

Reputation: 131
• Posts: 722
• Joined: 28-April 07

## Re: fixed ratio column width

Posted 10 October 2013 - 09:22 AM

Hello,

does any of these classes (data-section, mitte, eigenschaften) adjusts the table width, if not, the table width could be what you need to change

I change the table width to %100 and the two columns widths are changing to fit the extra space
they are not perfectly equal but I think it's not a bad result

### #3 Dormilich

• 痛覚残留

Reputation: 3541
• Posts: 10,226
• Joined: 08-June 10

## Re: fixed ratio column width

Posted 10 October 2013 - 10:54 AM

ahmad_511, on 10 October 2013 - 06:22 PM, said:

does any of these classes (data-section, mitte, eigenschaften) adjusts the table width

nope. just borders and colors.

ahmad_511, on 10 October 2013 - 06:22 PM, said:

if not, the table width could be what you need to change

set to 100%. if I were to use a fixed column layout, there were no problem.

ahmad_511, on 10 October 2013 - 06:22 PM, said:

I change the table width to %100 and the two columns widths are changing to fit the extra space
they are not perfectly equal but I think it's not a bad result

that is the current state and (since there are several such tables in sequence) the result is unpleasing.

### #4 andrewsw

• Fire giant boob nipple gun!

Reputation: 3462
• Posts: 11,729
• Joined: 12-December 12

## Re: fixed ratio column width

Posted 10 October 2013 - 11:35 AM

You might try changing the table-layout property to fixed or auto to change the algorithm used to render the tables.

Personally, I think this will be difficult to control, particularly cross-browser, without some Javascript.

This post has been edited by andrewsw: 10 October 2013 - 11:36 AM

### #5 Dormilich

• 痛覚残留

Reputation: 3541
• Posts: 10,226
• Joined: 08-June 10

## Re: fixed ratio column width

Posted 10 October 2013 - 11:56 AM

andrewsw, on 10 October 2013 - 08:35 PM, said:

You might try changing the table-layout property to fixed or auto to change the algorithm used to render the tables.

that seems to do the job. can tell you more when I’m at the real code tomorrow.

UPDATE: jupp, fixed fixed it.

This post has been edited by Dormilich: 10 October 2013 - 11:28 PM