0

Is it possible to determine the height of an element without attaching it first to the DOM? I'd like to determine the height ahead of time to pre-calculate absolute positions.

Charles Sounder
  • 591
  • 2
  • 5
  • 16
  • 2
    Position it offscreen and measure it. No one will know or see the element. (position:fixed;top:-9999px); – Ron Gilchrist Jan 13 '15 at 00:28
  • you may want to take a look at this: http://stackoverflow.com/questions/2345784/jquery-get-height-of-hidden-element-in-jquery – mmgross Jan 13 '15 at 00:32
  • 3
    The context into which the element is added to the DOM may have a tremendous impact on the size. Different parts of the page may have different font size rules, different widths, line heights, etc etc. In general, the answer is "no". – Pointy Jan 13 '15 at 00:32
  • I'm trying to avoid the expensive reflow and repaint process or at least limit the number of times this occurs. How do I do this? If I make all the elements I attach to my DOM hidden and then show them all at the end, would that achieve the desired effect? – Charles Sounder Jan 13 '15 at 00:43

0 Answers0