<p>To calculate a top position for an element of variable height, I was thinking of doing the following:</p>

<ol>
<li>Move the element 1000px off the top of the viewport</li>
<li>Set the element to display: block</li>
<li>Get the height of the element</li>
<li>Set the element to display: none</li>
<li>Continue on as if everything is normal and good</li>
</ol>

<p>Any pitfalls in this approach? Is there a more elegant solution?</p>

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.