I think this won't compensate for inter-element margins (getBoundingClientRect is only border-box not margin-box) and you'll want to calculate the distance between the tops of 2 (or similar) instead of just the height.  MSDN has a neat picture at http://msdn.microsoft.com/en-us/library/hh781509%28v=vs.85%29.aspx