Stretching a Table's Width to fit web browser
Asked Answered
V

2

7

I have scoured the internet for a long time trying to solve my problem. I have a table with my whole site in it and would like for it to stretch to fit the user's web browser size. Here is all the site's code:

<body>

<table width="100%" border="0">
  <tr>
    <td width="525" rowspan="2"><img src="My Images/Speaker.png" width="525" height="772"               
ondragstart="return false" />
    </td>

    <td width="697" height="16">
    *Flash Video Here*
    </td>
   </tr>
  <tr>
    <td><img src="My Images/Vymil.jpg" width="822" height="597" ondragstart="return false"/></td>
  </tr>
</table>

</body>
</html>

Any helpful solutions would be greatly appreciated.

Viscountess answered 9/1, 2011 at 4:51 Comment(0)
E
7

Give width in Percentage in <table> and <TD> tag. This it will set as per browser window size. Give 100% in <table> and appropriate percentages to every <TD>

Emetine answered 9/1, 2011 at 4:54 Comment(2)
Thanks for all the quick responses I've tried the above 2, and still no luck. Harry Joy I know that this is a possible solution I just didnt want to have to delve into percentages anymore wanted to know if there was a simpler solution to make the <TD> tags auto resize due to the parent tables resizingViscountess
@Tech0guy: No its not dependent on parent if you give size without percentage. It will be same for all browser sizes.Emetine
M
1
<style type="text/css">
*
{
    margin: 0px;
    padding: 0px;
}
html, body
{
    height: 100%;
}
</style>
<table style="width:100%;height:100%;">
<!-- content -->
</table>

This will ensure your table will stretch to your browser's size.

http://jsfiddle.net/L9wMU/

Mertz answered 9/1, 2011 at 4:57 Comment(2)
I added a test page for you to show how your code should look.Mertz
@Mertz thanks for sharing a propert snippet of code, that everyone can relate and understand too!Gloriagloriana

© 2022 - 2024 — McMap. All rights reserved.