Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

width of DIV

Status
Not open for further replies.

joelmac

Programmer
Jun 4, 2002
92
CA
Hi there,

I'm creating DIVs on a page with the createElement function and setting the position style to absolute. Each DIV has a different amount of text in it so the width of each DIV is different. I want to place the DIVs in a row. I can get the left and top perporties, but I can't get the width. How can I get the width of a DIV when it's not explicitly set?

Thanks,

________________________
JoelMac
 
That is one of those frustrating things - you cannot. Unless you explicitly set the width of an element, you cannot read it.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Bummer! Well at least I know now

Thanks for the info

________________________
JoelMac
 

You actually can.

I posted a thread about it ages ago but the forum isn't working properly so I can't link to it. Do a search on getComputedStyle and currentStyle.
 
I tried the currentStyle, but it only works if the property is explicitly set. Otherwise it returns 'auto'.

I couldn't get getComputedStyle to work in IE.

It only has to work in IE.

Any other ideas?

________________________
JoelMac
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top