Link to home
Start Free TrialLog in
Avatar of HalCHub
HalCHubFlag for United States of America

asked on

width of a table column

given

<table >
<tr><td width="20%">asddasd</td><td width="80%">dsdadds</td></tr></table>
when I check objectid.width I get "20%" and "80%".

What is this 20% and 80% of and how can I get the actual px of each ?
Avatar of Gary
Gary
Flag of Ireland image

You can't, percentages are proportional based on browser size. You could take a screenshot and then use something like Photoshop to get the actual size.
ASKER CERTIFIED SOLUTION
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Addendum to my comment
That would be the actual size as of that instance, once you resize the browser those values (px) will change again.
Agreed, and apologies if i duplicate what is in the article posted. But unless you capture the size of the window at the time you cant do this. for example, window width = 1000, then:

1000 * 0.2 = 200 (0.2 being 20%)

But this is complicated because you would have to do this every time the window is resized which would include some ajax calls. On a windows form it wouldbt be a problem, on a web page its a completely different ball game.

Here is some javascript to the get window size, however by the sound of things you would need to manipulate it from the code behind which involves submitting this info to the server in order to do this, you could stick it in a hidden field and do it that way:

http://mauzon.com/how-to-get-real-window-width/

All together, not a recommened operation. What are you trying to achieve?
You could use it like this.
Give your Table Main, a set width, and then set the percentage between the 2 columns.
If I have misunderstood the question, please disregard.
Carrzkiss
<style type="text/css">
#MainTD{
	width:700px;
}
.tdR{
	width:80%;
}
.tdL{
	width:20%
}
</style>
</head>

<body>
<table id="MainTD">
<tr><td class="tdL">Something here</td><td class="tdR">Something here right here in the bigger area</td></tr>
</table>

Open in new window

Avatar of HalCHub

ASKER

so there is no way to query what the actual column width is when it is rendered ....
No the values are dynamic, all you could get is the width at load but that will change with browser size.