PDA

View Full Version : Browser/table auto resizing



thb
03-26-2006, 10:48 AM
How do I automatically resize a table whenever the viewer resizes his browser window? If the window is big, then more columns should be visible. (The table also has vertical and horizontal scroll bars.)

This should be similar to Googlw Maps where the map becomes smaller/bigger as you resize your window. Do they constantly reload?

Thanks!

djr33
03-26-2006, 11:06 AM
I'm confused.

All you need to do to make table size relate to window size is use percents:
<table width=50% height=50%>, etc. The same can be applied to <td> and <tr> as well.
That will make it relate to how much space it has. (If its smaller than the window, say in the cell of another table, then it will just be x% of that space.

That should solve your problem.

Except... you said that 'more columns should be visable' 'if the window is big', so.... hmm?

Twey
03-26-2006, 11:46 AM
If more columns become visible as the window's size is increased, then the table's size must be staying the same :)
djr33: As the values for height and width you specified contain %, a non-numeric character, you need to surround them with quotes:
<table width="50%" height="50%">

thb
03-26-2006, 11:47 AM
Right, the width/height of the columns/rows must not change. Like Google Maps - the map doesn't get distorted when the window resizes, you just see less.

You're right, the table doesn't change size, just how much of it you see. Maybe if I put it inside a div container with a % height/width???

Twey
03-26-2006, 12:07 PM
Yes, that would work. The content would need to have a fixed height/width, though, in pixels.

thb
03-26-2006, 01:27 PM
Yup, it worked :)