Solved

dynamic table width

Posted on 2008-06-24
6
1,536 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
css, html 5 43
Why my select dropdown does not work? 8 41
How to make footer stick to bottom 9 31
Can't get container centered 4 16
Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article discusses four methods for overlaying images in a container on a web page
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

825 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