Close gh-51. Account for top and left margins when calculating inverted containment.