Trying to figure out if some content fits within its max-height limit, but the line-height is throwing off my calculations.
This is how I'm trying to determine if the content is partially hidden:
var partiallyHidden = content.scrollHeight > content.offsetHeight;
However, it seems like the line-height of the content is impacting the accuracy of this code. What role does line-height play in relation to scrollHeight/scrollOffset? Are there other factors I need to take into account?
Check out the full example here.
Also, keep in mind that the solution needs to be compatible with IE9+.
Additional notes:
- I came across the formula
in a Stack Overflow post.content.scrollHeight > content.offsetHeight
- The code from a related question on Stack Overflow (link) gave me the same error. The use of
clientHeight
versusscrollOffset
is confusing in terms of the result it produces.