Reputation: 21796
To calculate a top position for an element of variable height, I was thinking of doing the following:
Any pitfalls in this approach? Is there a more elegant solution?
Upvotes: 1
Views: 513
Reputation: 61223
can you not just set the visibility to hidden and get the offsetHeight?
Upvotes: 0
Reputation: 8376
I'd look at prototype's implementation of getDimensions
.
It sets the position to absolute, visibility to hidden, and display to block briefly. I've written one which handles getting the height of something which is contained within a display:none
element, but it's a bit shonky in some edge cases.
Upvotes: 3