Google Answers Logo
View Question
 
Q: How to lock the height of a table cell and specify another should fill the gap ( Answered 4 out of 5 stars,   0 Comments )
Question  
Subject: How to lock the height of a table cell and specify another should fill the gap
Category: Computers > Programming
Asked by: horseradish-ga
List Price: $2.00
Posted: 26 Sep 2003 05:00 PDT
Expires: 26 Oct 2003 04:00 PST
Question ID: 260389
I thought I knew tables but this little problem is driving me nuts!
Please take a look at http://www.redjam.com/table_problem.html

How can I 'lock' the upper left cell (1) and get the lower left
cell(3) to stretch to fit the space? I have tried putting a percentage
height for cell 3 but that doesn't work. The only way seems to be to
specify a fixed height for cell 3 that corresponds to the height of
cell 2. But as the content of cell 2 is always variable, that would
mean cosntantly having to go and tweak the height of cell 3. No good!
Answer  
Subject: Re: How to lock the height of a table cell and specify another should fill the g
Answered By: serenata-ga on 26 Sep 2003 07:22 PDT
Rated:4 out of 5 stars
 
Hi Horseradish ~

The best way to accomplish what you want to accomplish is to make a
one row, two cell table, instead of using two rows.

Give your left hand cell a grey background.
Give your first embedded table (what you're calling "cell 1") a white
background.

That way, both sides will expand in height to handle whatever you put
in the right hand side.

Here's your coding redone to show you - and I left your text in there
and tested the results in five browsers, and it looks as you want it
in

   IE 5.5
   Mozilla 1.4
   Netscape 4.79
   IE 6.x
   Opera 7


============
<html>
<head>
	<title>Untitled</title>
</head>
<body>
<table border="1" width="540" cellspacing="0" cellpadding="0">
   <tr>
      <td valign="top" bgcolor="#cccccc" width=125>

      <table border="1" bgcolor="ffffff" width="125" height="125"
cellspacing="0" cellpadding="0">
      <tr>
        <td height=125><font size="1" color="#000000" face="helvetica,
arial">Cell 1 is fixed height of 125 pixels. Here it contains a table
that's 125 pixels high and a red gif that's 125 pixels high. There
should be no extra space below this table.</font></td>
        <td><img src="graphics/pxred.gif" alt="" height="125"
width="10"></td>
     </tr>
     </table>

<font size="1" color="#000000" face="helvetica, arial">
Cell 3. This grey cell should stretch to account for all the extra
space created by Cell 2.</font>
</td>

<td width=415><font size="1" color="#000000" face="helvetica,
arial">Cell 2 is full of text and stretches to variable heights, can
sometimes be very long, causing the problem described to occur.Cell 2
is full of text and stretches, can sometimes be very long, causing the
problem described to occur.Cell 2 is full of text and stretches, can
sometimes be very long, causing the problem described to occur.Cell 2
is full of text and stretches, can sometimes be very long, causing the
problem described to occur.Cell 2 is full of text and stretches, can
sometimes be very long, causing the problem described to occur.Cell 2
is full of text and stretches, can sometimes be very long, causing the
problem described to occur.

<p>Cell 2 is full of text and stretches, can sometimes be very long,
causing the problem described to occur.Cell 2 is full of text and
stretches, can sometimes be very long, causing the problem described
to occur.Cell 2 is full of text and stretches, can sometimes be very
long, causing the problem described to occur.Cell 2 is full of text
and stretches, can sometimes be very long, causing the problem
described to occur.Cell 2 is full of text and stretches, can sometimes
be very long, causing the problem described to occur.

<p>Cell 2 is full of text and stretches, can sometimes be very long,
causing the problem described to occur.Cell 2 is full of text and
stretches, can sometimes be very long, causing the problem described
to occur.Cell 2 is full of text and stretches, can sometimes be very
long, causing the problem described to occur.Cell 2 is full of text
and stretches, can sometimes be very long, causing the problem
described to occur.Cell 2 is full of text and stretches, can sometimes
be very long, causing the problem described to occur.Cell 2 is full of
text and stretches, can sometimes be very long, causing the problem
described to occur.Cell 2 is full of text and stretches, can sometimes
be very long, causing the problem described to occur.Cell 2 is full of
text and stretches, can sometimes be very long, causing the problem
described to occur.Cell 2 is full of text and stretches, can sometimes
be very long, causing the problem described to occur.Cell 2 is full of
text and stretches, can sometimes be very long, causing the problem
described to occur.</font></td>
	</tr>
</table>
</body>
</html>
======================

When you're embedding tables, things can sometimes get a bit dicey,
but this accomplishes what you want as you've designed it.

Using cascading style sheets would eliminate the need to embed tables
within tables, but that's a whole different question.

Good luck!

Serenata

Request for Answer Clarification by horseradish-ga on 26 Sep 2003 08:35 PDT
Thanks very much for your full answer and for taking the time to re-do
the code and test it.
I see how this works, but unfortunately in my case it wouldn't be
right. I was trying to be simplistic about the problem with my example
but perhaps I need to explain further what I'm trying to do. I need to
have the separate table cell because the table at the top is pulled in
as a library item, and the image that will go in the lower cell
changes depending on the content of the main right hand cell!
So cell 1 is specifically defined as the cell that contains library
content, and cell 2 is specifically for the image, which means I'm
back to my question of how to fix the height of cell 1 and to specify
that cell 2's height should be variable.
Thanks for thinking laterally though. I will try to think if there is
a way to adjust my code to your solution, though it's all ensconsed in
lots of perl script and various templates so I think it would be much
more difficult.
Best wishes :-)

Request for Answer Clarification by horseradish-ga on 26 Sep 2003 08:37 PDT
Sorry - when I was talking about cell 2 in that last answer I meant cell 3!

Clarification of Answer by serenata-ga on 26 Sep 2003 09:27 PDT
Even drawing data from a database or other sources, it would still fit
in the left under that embedded table and allow for the expansion.

In the right hand side, you were spanning the two rows anyway, but you
either have to LIMIT that left hand side's height to 125 pixels or
you'll still end up with the gap.

This way, you control the placement with html, or you can attempt
absolute positioning of that upper left hand table (white background)
using CSS, but then you end up with browser interpretations.

The fact that you were spanning the rows (and not columns) is why it
will work.

Best regards,
Serenata

Request for Answer Clarification by horseradish-ga on 26 Sep 2003 13:03 PDT
Yes, you're right, with a bit of tweaking I can get it to appear in
the same place, so it's solved now, thank you.
I'd still be interested to know if it is possible to do what I wanted
though, as it seems a bit of a glitch that the cell automatically
split to half the height, even when one has its height specified.
Maybe I should ask the browser people about that :-)

Clarification of Answer by serenata-ga on 26 Sep 2003 14:06 PDT
This has to do with spanning the two rows.

Try your first way, but remove the height=80% from the second row, and
it seems to work that way, too.

Sorry for that ... I'd lost that somehow. By removing any height
restrictions (and keeping your span), that second row automatically
"kicks in" after the 125 pixel height restriction of the first row.

Serenata
horseradish-ga rated this answer:4 out of 5 stars
A very good and full lateral-thinking response, which achived the same
end result I was looking for. But I'd still like to know that answer
to my original question!

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy