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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to size cells within an HTML table ?

Status
Not open for further replies.

vilrbn

Programmer
Oct 29, 2002
105
0
0
FR
Hello,

I want my application to be resized depending on the screen resolution.
I put all my controls in HTML tables with a percentage as width.
I tried to put the percentage on the table + cells / fields / row and it never adapt the cells to the values I set.

Here is my code:

<table cellSpacing=&quot;2&quot; cellPadding=&quot;2&quot; width=&quot;70%&quot; border=&quot;1&quot; runat=&quot;server&quot; ID=&quot;Table1&quot;>
<tr>
<TD width=&quot;40%&quot;><asp:label id=&quot;lbl&quot; runat=&quot;server&quot;>Vendor Code to search for:</asp:label></TD>
<TD width=&quot;5%&quot;><asp:textbox id=&quot;txt0&quot; tabIndex=&quot;1&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot; MaxLength=&quot;4&quot;></asp:textbox></TD>
<TD width=&quot;5%&quot;><asp:textbox id=&quot;txt1&quot; tabIndex=&quot;2&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot; MaxLength=&quot;4&quot; Enabled=&quot;False&quot;></asp:textbox></TD>
<TD width=&quot;5%&quot;><asp:textbox id=&quot;txt2&quot; tabIndex=&quot;3&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot; MaxLength=&quot;4&quot; Enabled=&quot;False&quot;></asp:textbox></TD>
<td width=&quot;5%&quot;><asp:textbox id=&quot;txt3&quot; tabIndex=&quot;4&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot; MaxLength=&quot;4&quot; Enabled=&quot;False&quot;></asp:textbox></td>
<td width=&quot;5%&quot;><asp:textbox id=&quot;txt4&quot; tabIndex=&quot;5&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot; MaxLength=&quot;4&quot; Enabled=&quot;False&quot;></asp:textbox></td>
<td width=&quot;5%&quot;><asp:textbox id=&quot;txt5&quot; tabIndex=&quot;6&quot; runat=&quot;server&quot; AutoPostBack=&quot;True&quot; MaxLength=&quot;4&quot; Enabled=&quot;False&quot;></asp:textbox></td>
</tr>
</table>

I also tried to copy this table to a new form and have the same problem.
Is there a special attribute to set ?

Thanks for your help !

 
Well, for starters, combined, all of your table cells should equal up to 100% (they currently sum up to 70%).

This should fix any problems that you are having:

<table cellspacing=2 cellpadding=2 width=70% border=1 runat=server id=table1>
<tr>
<td width=40%>...</td>
<td width=10%>...</td>
<td width=10%>...</td>
<td width=10%>...</td>
<td width=10%>...</td>
<td width=10%>...</td>
<td width=10%>...</td>
</tr>
</table>

Let me know if that helps =D

-----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
Cells sum = 70% as I set the table width to 70%.
Even if I change them from 70% to 100% there's no change.
 
The actual table will stay at 70% of the client browser window (try re-sizing your own browser window).

When you set the size of the cells, you are setting them to the size of the table, not the page.

You may also want to set the width of the textboxes (width=100%). If the width of the textboxes are set explicitly, the cells of the table will only decrease to the width of the textboxes. Also, if the width is not set as a percentage, the textboxes will not re-size depending on the client browser.

Make sense?

-----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
How can we adapt our applications to the screen size ?
If it doesn't fit the page but the table...
In my example, my first field (width = 40%) is the smallest !! Other ones have a width=10% !!!
I also tried to change the controls size, with same problem.
 
I finally set percentages on each fields without using an HTML table and it's solving my problem.
Thanks for your help !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top