Solved

dynamic table width

Posted on 2008-06-24
6
1,537 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
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
Industry Leaders: 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
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.…

713 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