Login Register

Always squared DIV in container DIV: dojo.style dimensions error in IE7

I've a container DIV that has its dimensions set in percentages:

#container { position:absolute; top:10%; left:20%; width:60%; height:80%; border:1px dashed #bbb; }

Within this container DIV, I want to create another DIV that is always squared; relative to the maximum container dimensions. This works fine in FireFox and Safari by retrieving the container dimensions with dojo.style() and doing some simple math, since the dimensions are transformed into pixels from their percentage values. But in IE, the dimension attributes are all in percentages, so the "square" calculation fails.

Any clue how to get this working in IE?

dojo.coords(node); might

dojo.coords(node);

might work for you.

Yep, /* GeSHi (C) 2004 -

Yep, dojo.coords() does the trick.

Thx frankf!