Solved

dynamic table width

Posted on 2008-06-24
6
1,539 Views
Last Modified: 2008-06-30
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
Comment
Question by:vbnewbie01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Accepted Solution

by:
mriz81 earned 100 total points
ID: 21859086
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
 
LVL 19

Expert Comment

by:erikTsomik
ID: 21859126
why don;y you use % FOR THE WIDTH
0
 
LVL 1

Author Comment

by:vbnewbie01
ID: 21860390
hi, erikTsomik; how would using percentage retain the exact width of the longest text in the first column?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:msfletch
ID: 21860518
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
 
LVL 1

Author Comment

by:vbnewbie01
ID: 21861487
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
 
LVL 4

Expert Comment

by:msfletch
ID: 21861516
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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question