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

#1 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • 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>
        <thead>
          <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>
        </thead>
        <tbody>
          <tr>
            <td class="links">Armbrust</td>
            <td>C</td>
            <td>24</td>
            <td></td>
            <td>16</td>
            <td class="links">Wurfmesser</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

#2 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

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

Re: fixed ratio column width

Posted 10 October 2013 - 10:54 AM

View Postahmad_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.

View Postahmad_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.

View Postahmad_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.
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3462
  • View blog
  • 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

Was This Post Helpful? 2
  • +
  • -

#5 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

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

Re: fixed ratio column width

Posted 10 October 2013 - 11:56 AM

View Postandrewsw, 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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1