If I'm reading [1] right, you want to use getBoundingClientRect() instead of clientHeight, which does not account for borders and margins.
1: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_...
1: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_...