Page 1 of 1

Tabled By Resizing Table

Posted: Mon Jul 11, 2005 6:45 pm
by Majoraslayer
Is there a way I can keep a table from resizing when the content seems to stretch it? I'm trying to put a form field in my banner table, and my banner is set as the background to the table. So, the table has to stay the same size as the banner or it starts repeating. When I put in the form field, its properly aligned with the text but it stretches the table underneath it. The text alone doesn't stretch the table. Is there a way to set the table to where it won't stretch and always stays the same size?

Posted: Mon Jul 11, 2005 9:43 pm
by shoebappa
As far as I know, you can't prevent a table from stretching if you put something inside it that's wider than the table width.

Code: Select all

<table width=&quote;100&quote;>
  <tr>
     <td width=&quote;100&quote;>
       <img src=&quote;spacer.gif&quote; width=&quote;150&quote; height=&quote;150&quote; />
     </td>
  </tr>
</table>
Would make a table that's 150x150pixels.

Code: Select all

<table width=&quote;100&quote;>
  <tr>
     <td width=&quote;100&quote;>
       <img src=&quote;spacer.gif&quote; width=&quote;10&quote; height=&quote;150&quote; />
     </td>
  </tr>
</table>
Would make a table that's 100x150pixels. Make sure you set the form field's size attribute to something lower than the width of the table. If you're dealing with backgrounds, it's probably best to try to make the background tile gracefully, but you can usually make it work right on most browsers by specifying size of images, nested tables, and form fields.

If it's stretching vertically, IE puts a wierd space below <form> tags, so I usually try to put the form tags outside of the table, or sometimes in between <td> tags. I know it's not valid, but it eliminates the little space in IE...

Code: Select all

<table>
  <tr>
    <form>
      <td>
        <input>
      </td>
    </form>
  </tr>
</table>
If anyone else knows a way to get rid of the spacing around a form, I'd love to hear it.

Posted: Mon Jul 11, 2005 10:09 pm
by Majoraslayer
My problem is vertical stretching. I think its in td tags already, but you can have a look at it at http://www.zorasdomain.com/index.php. You'll figure out quickly what I'm talking about.

Posted: Mon Jul 11, 2005 10:19 pm
by Majoraslayer
I did a Google search, and found the following trick you might like to know about:
An Unknown Site wrote: To prevent extra spacing below a form, it is usually sufficient to set the form element’s bottom margin to zero, e.g.
<form style="margin-bottom: 0" ...>
However, for older browsers, additional methods might be needed.