Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

%,min,max size table

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
is it possible to give a table a 100 % height value, but at the same time give it a minimum and maximum height?

example
a table is 100% height, so it resizes as the browser window is resized. If the resized browser window height is less than X then the table will freeze at 300 pixels height and a scrollbar will apear for the rest. On the other hand if the browser window height is more than Y the table will freeze at 800 pixels.





I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
You need to use spacer images to achieve this.
Just create a transparent image 1px x 1px
Code:
<table width="100%">
  <tr>
    <td rowspan="2" scope="row"><img src="/images/spacer.gif" width="1" height="300">test</th>
    <td colspan="4"><img src="/images/spacer.gif" width="800">test</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

[cheers]
Cheers!
Laura
 
that sets the 100% height and minimum size, but how can i set the table to not get higher than 800 px?


I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
sorry the height larger than 800px or the width larger than 800px?

If it's width: use a nested table - just set the container table width to 800px like so:
Code:
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">
      <table width="100%">
        <tr>
          <td rowspan="2" scope="row"><img src="/images/spacer.gif" width="1" height="300">test</th>
          <td colspan="4"><img src="/images/spacer.gif" width="800">test</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
If you're looking to limit height, I'm not sure if you can. Eventually the contents will wrap, and force a scroll down.

[cheers]
Cheers!
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top