Click here to get back home

table issue, centered column not possible, when text in other columns

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
table issue, centered column not possible, when text in other columns joes 09-01-2007
Get Chitika Premium
Posted by joes on September 1, 2007, 3:34 pm
Please log in for more thread options


Hello

I have strange issue with tables. I like to have table with 3 columns
where the middle column is fixed an the other 2 columns are relative,
using the rest max width. Effect is that the middle area is centered.
So far no issue, Example

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td width="704">centered column</td>
<td>&nbsp;</td>
</tr>
</table>

When I like to add some text in the first column " T E X T", the
column width is "exploding" so that the centered column moves to right
and the last column is shrinked nearly to nothing.

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> T E X T </td>
<td width="704">centered column</td>
<td>&nbsp;</td>
</tr>
</table>

I noticed this issue in IE 6.0 and also in FireFox 2. Can anyone
explain what here is happing and why the first and last column are not
longer sharing the rest of the space so that the middle column appears
centered?

Any idea to reach such a design that I can position the " T E X T"
right aligned to the centered column so that when the size of the
browser changes it stills aligned centered?

i.e.

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="right"> T E X T </td>
<td width="704">centered column</td>
<td>&nbsp;</td>
</tr>
</table>

many thanks in advance

regards
joes


Posted by Ben C on September 1, 2007, 4:34 pm
Please log in for more thread options


> Hello
>
> I have strange issue with tables. I like to have table with 3 columns
> where the middle column is fixed an the other 2 columns are relative,
> using the rest max width. Effect is that the middle area is centered.
> So far no issue, Example
>
><table width="100%" border="1" cellspacing="0" cellpadding="0">
> <tr>
> <td>&nbsp;</td>
> <td width="704">centered column</td>
> <td>&nbsp;</td>
> </tr>
></table>
>
> When I like to add some text in the first column " T E X T", the
> column width is "exploding" so that the centered column moves to right
> and the last column is shrinked nearly to nothing.
>
><table width="100%" border="1" cellspacing="0" cellpadding="0">
> <tr>
> <td> T E X T </td>
> <td width="704">centered column</td>
> <td>&nbsp;</td>
> </tr>
></table>
>
> I noticed this issue in IE 6.0 and also in FireFox 2. Can anyone
> explain what here is happing and why the first and last column are not
> longer sharing the rest of the space so that the middle column appears
> centered?

You asked for the middle cell to be 704px wide, and for the whole table
to be 100% wide. Suppose the available space is 1250px (this depends on
the size the user makes her window). That means the total width of cells
1 and 3 must be 546px.

How much of that should go in cell 1 and how much in cell 3? It's not
defined precisely by the specification. Browsers don't have to
distribute the 546px evenly between the two cells (the thing you want).
In fact what they are quite likely doing is distributing more of the
extra width to cell 1 because its preferred width (the width of the text
in it with no line breaks) is greater. Generally that strategy is
preferable for a real table containing tabular data since it tends to
keep cell widths closer to the widths of their contents.

> Any idea to reach such a design that I can position the " T E X T"
> right aligned to the centered column so that when the size of the
> browser changes it stills aligned centered?

I'm not sure I understand what you're asking for. You want the 704px
thing centered in the viewport, with "T E X T" hanging off to the left
of it?

><table width="100%" border="1" cellspacing="0" cellpadding="0">
> <tr>
> <td align="right"> T E X T </td>
> <td width="704">centered column</td>
> <td>&nbsp;</td>
> </tr>
></table>

If you add width="10%" to the first and third cells you get what (I
think) you want in some browsers at widths at least > 800px.

But I don't recommend this as it's really very dodgy. We're asking for a
set of things that can't all be satisfied except at one precise viewport
width: for the table to be 100% of the viewport, its middle cell to be
704px and the cells either side of it to be 10% of the total table
width.

We're relying on the browser interpreting this as: of all the things
you've asked for, the 704px width for the middle cell is the most
important; but since the cells either side both want to be 10%, at least
make them the same widths as each other. This is skating on thin ice.

You need to provide more context and explain what this is for because
there is probably a much simpler way perhaps with a small compromise of
your design. If for example "T E X T" is actually an image, or something
with a known or styled width, then there are a lot more options.

Posted by joes on September 1, 2007, 5:10 pm
Please log in for more thread options



> How much of that should go in cell 1 and how much in cell 3? It's not
> defined precisely by the specification. Browsers don't have to
> distribute the 546px evenly between the two cells (the thing you want).
> In fact what they are quite likely doing is distributing more of the
> extra width to cell 1 because its preferred width (the width of the text
> in it with no line breaks) is greater. Generally that strategy is
> preferable for a real table containing tabular data since it tends to
> keep cell widths closer to the widths of their contents.

Many thanks for your answer. This sounds logical and explains why it
is happening

> You need to provide more context and explain what this is for because
> there is probably a much simpler way perhaps with a small compromise of
> your design. If for example "T E X T" is actually an image, or something
> with a known or styled width, then there are a lot more options.

The deisgn is simple which I like to reach, is tI like to have a
centered area for the content. If the browser
window resizes the conent area should stay centered. But leftto the
center I like to have just a label, a text which
shows you on which chosen menu you are.

So any idea how I can reach this? A workaround would be to add the
same text in the last column too and set
the color to the same one as the back ground, but I think there should
be more a logical way.

regards
joes




Posted by Ben C on September 2, 2007, 3:42 am
Please log in for more thread options


[...]
> The deisgn is simple which I like to reach, is tI like to have a
> centered area for the content. If the browser
> window resizes the conent area should stay centered. But leftto the
> center I like to have just a label, a text which
> shows you on which chosen menu you are.
>
> So any idea how I can reach this? A workaround would be to add the
> same text in the last column too and set
> the color to the same one as the back ground, but I think there should
> be more a logical way.

The obvious way is to do this:

<div style="margin: 0 auto; position: relative;
width: 704px; background-color: pink">
centered column
<div style="position: absolute; right: 704px; top: 0">
TEXT
</div>
</div>

This centers "centered column" and then positions "TEXT" off to the left
of it.

But Opera has a bit of a problem with it. If you ask me, it's not
implementing CSS 2.1 10.3.7.1 correctly-- it's solving for right not
left. Maybe fixed in a newer version, I tested on 8.02 which is quite
old.

Similar ThreadsPosted
Three column layout, middle column clear:both; affects other two columns;no tables March 9, 2007, 11:31 pm
Implied width of implied center column in 3 column table June 30, 2008, 4:23 am
Problem positioning text over an centered image September 22, 2005, 6:07 pm
Manipulating a two-column table? March 8, 2006, 12:09 pm
Trying to position table columns December 28, 2005, 9:43 am
Text and images in irregular shaped column(s) October 21, 2005, 9:45 am
Freeze Table Columns in HTML August 30, 2006, 2:12 pm
fixing column width in a dynamic table December 13, 2005, 8:56 am
Why are we experiencing a table sizing issue with set pixel widths? May 21, 2008, 3:48 pm
Thai text rendering issue in browser (line breaks) March 10, 2005, 5:38 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap