Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 17th, 2005, 05:32 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default Table column to stretch height on long page

Firstly, I am new to web development...so here goes...

(see code example below)I have a table with 5 rows and 3 columns. Basically I want the green rows to stretch when there is a lot of info in the middle (blue cell)

The red cells are to stay fixed height 295px

The problem is that when there is a lot of data in the middle (blue cell) then the red rows expand in height, and they shouldn't. Its the green cells I want to stretch. I think they (red and green cells) stretch proportionately.

To test the example - copy to html page and view. Then paste a lot of text in where it says - Paste a lot of text here - and you will see the problem.

Let me know if you need any further info, I hope I have given enough detail. The problem is in IE.

Thanks

Nickie

Code:
<table>
<tr>
    <td colspan="3" bgcolor="fuchsia">top row, colspan 3</td>
</tr>
<tr>
    <td height="295px" bgcolor="red">1 - 1</td>
    <td rowspan="3" bgcolor="blue">2 - 1

Paste a lot of text here

    </td>
    <td height="295px" bgcolor="red">3 - 1</td>
</tr>
<tr>
    <td height="100%" bgcolor="green">1 - 2</td>
    <td height="100%" bgcolor="green">3 - 2</td>
</tr>
<tr>
    <td height="295px" bgcolor="red">1 - 3</td>
    <td height="295px" bgcolor="red">3 - 3</td>
</tr>
<tr>
    <td colspan="3" bgcolor="fuchsia">bottom row, colspan 3</td>
</tr>
 
Old October 17th, 2005, 05:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What you are looking for is probably the following style sheet property and value...
Code:
white-space:nowrap;
Therefore, apply the CSS property and value to the table cells which shouldn't wrap.

Hope it helps, Jacob.
 
Old October 17th, 2005, 05:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Moreover, you say that you are new to web development then you should probably look into style sheets instead of using HTML attributes for styling; e.g. when coloring the cells etc. Try this one...

http://www.google.dk/search?hl=da&q=...rial+CSS&meta=

Jacob.
 
Old October 17th, 2005, 06:03 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I have got a stylesheet but just didn't use it in this cut down example - I only put the colours in to help describe where the problem was.

Thanks for your prompt response, but I'm not sure what you mean by "table cells which shouldn't wrap" e.g where to put the property white-space.

Cheers

Nickie
 
Old October 17th, 2005, 06:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Alright, you have a few options, the first and not so beautiful is simply to apply the style to each cell individually, like this...
Code:
<td rowspan="3" bgcolor="blue" style="white-space: nowrap;">2 - 1 Paste a lot of text here</td>
... another way is more flexible. You apply a class to each of the cells that you want to have nowrap on. Therefore e.g.
Code:
<td rowspan="3" class"withoutwrap red">2 - 1 Paste a lot of text here</td>
... and then you have defined the class nwrap in your style sheet with the property, E.g.
Code:
.withoutwrap { white-space: nowrap; }
.red { background-color:#ff0000; }
In this small example I also demonstrated that you can actually have more than one class for each element. You can put the background color in one class and the wrapping in another and apply both to the same element.

Jacob.

(not tested, but should work)
 
Old October 17th, 2005, 06:30 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

The method I'm going to use is the second way you described but I tried both ways and still get the same results. e.g. the red cells still expand.

Nickie
 
Old October 17th, 2005, 06:34 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hold on - got it working in the small example - let me apply that to the main project and see what happens.

Nickie
 
Old October 17th, 2005, 06:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you say expand do you then mean vertically? You have set your height to 295px.

Jacob.
 
Old October 17th, 2005, 06:44 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Yup - they still expand vertically.

and my mistake i though the example worked but it didn't i still get the same result.

I have got the height set for the red cells but not the blue cells.

Cheers

Nickie
 
Old October 17th, 2005, 07:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry Nickie, I misunderstood your problem. Now I see what you are trying to do. Unfortunately I have no solution now. It is definately not a nowrap problem!

Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Data too long for column 'ResumeInfo' at row 1 Snowby Pro PHP 0 April 2nd, 2008 02:32 AM
stop page stretch on PHPBB2 board crmpicco HTML Code Clinic 2 January 21st, 2008 06:42 PM
Fixed table height and row height rajanikrishna HTML Code Clinic 3 January 18th, 2007 12:42 AM
Dynamic table on specific height of JSP page shoaibkhan2000 Pro JSP 0 August 1st, 2006 06:15 AM
convert long column into rows bdmoody Classic ASP Basics 2 August 7th, 2004 01:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.