title: Is it possible in Chrome to avoid "jumping" of the viewport when hidden elements are removed from the DOM?
body: <p>I am building a web app where - as part of the UI - I have an occasional, temporary need for some extra elements in the DOM, which are therefore dynamically inserted. When they have served their purpose, they are hidden and then for good measure removed using jQuery's .remove().</p>
  
  <p>For some reason, removing the elements creates a jump and a relocation of the viewport contents (reside within an iFrame) as if it is re-rendered despite the fact that the elements are hidden and therefore should not have any influence on the rendering of the content.</p>
  
  <p>I have tried to remove the elements from the console instead of in my script and the jump still occurs. I have also seen a similar effect in Firefox.</p>
  
  <p>I might end up keeping the elements if there is no solution, but if any of you have experience with a similar scenario and know of a solution, I would be very interested to hear it. Thank you very much.</p>
  
  <p>UPDATE</p>
  
  <p>After much scrutiny, I have finally pinned down the cause of this "error". It originates at the beginning of the content, which starts out with a h1 headline. The headlines have been styled with a top padding, except for the first child, where it is set to zero with a h1:first-child rule. </p>
  
  <p>Now, the dynamic elements are inserted at various locations including before the first headline. Apparently, the dynamic element now becomes the first-child even though it is not rendered and therefore the general padding rule for the headlines becomes active and the headline receives a top padding. This causes it to jump up when the dynamic element is removed and it again gets a top padding of zero.</p>
  
  <p>So I know the cause of this but I am not sure how to best solve the problem since the content as well as the styling is dynamic - ie. I do not control it and therefore can not simply replace the first-child rule with something more suitable.</p>
  
  <p>IMHO it is completely unintuitive that the first-child rule is affected by elements that should be taken out of the document flow with display:none. It should only take "visible" elements into account.</p>