[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1542
  • Last Modified:

dynamic table width

hi there; i have a 700px table with 2 columns and many rows.

the first column has to be a dynamic width (i.e. as long as the longest content ... so if row 1 is 200px and row 2 is 240px and row 3 is 140px then the entire column will be 240px)

the second column has to be the remaining width (i.e.  if column 1 is 240px then column 2 is 460px ... if column 1 is 200px then column 2 is 500px etc ...)

can someone explain how i would accomplish this.

thanks.
0
vbnewbie01
Asked:
vbnewbie01
1 Solution
 
mriz81Commented:
You can achieve this by setting with of your second column to 700 and leave width attribute for first column. So a code like below can work for you
<table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>TestString</td>
    <td width="700">&nbsp;</td>
  </tr>
  <tr>
    <td>TestString_TestString</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>TestString_TestString_TestString</td>
    <td>&nbsp;</td>
  </tr>
</table>

Open in new window

0
 
erikTsomikSystem Architect, CF programmer Commented:
why don;y you use % FOR THE WIDTH
0
 
vbnewbie01Author Commented:
hi, erikTsomik; how would using percentage retain the exact width of the longest text in the first column?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
msfletchCommented:
You can try this:

<table width=700>
<tr>
    <td width=10 nowrap>Width 10 means at least ten, with no wrap it will stretch to fit content.</td>
    <td width="*">Star means everything left over to the width of the table</td>
</tr>
</table>
0
 
vbnewbie01Author Commented:
hi, msfletch; thanks for your suggestion.  i think i will go with mriz81's suggestion as i prefer not to have any minimum widths.  still waiting for erikTsomik's response before i ultimately decide though.  thanks again.
0
 
msfletchCommented:
At least you have something that works! =) The answer to erikTsomik's question is that it wouldn't retain the exact width.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now