I need to read CSS settings for the div’s width and height etc in jQuery to arrange the divs (hundreds of them) in proper position in the page.
I know it is possible to read an existing div’s actual size/position. But my requirement is to get the info before the div even exists. Anybody? Thanks!
Sorry, I didn’t make it clear enough. Here is my situation:
I have a big parent div, which is going to hold multiple rows and columns of small divs.
The parent div is like 1000 x 1000 px. The small divs like 15 x 10 but it is configed in CSS, and its real value I don’t know.
I need to calculate how many row and columns to array the matrix of divs. So that I can loop through to arrange them in the parent div.
Hope this is a better description.
Have a look at the compatibility page for DOM CSS. You should be able to access the rules of a stylesheet before any divs are created on the page, and without creating “dummy” divs. For example,
That would show you the height value of the first rule in the first stylesheet.