Skip to content Skip to sidebar Skip to footer

Outer Element Margin Not Equal To Inner Element Margin

I am using an Android WebView to display my app's HTML content. I need to dynamically find the full height of an element (usually a div) including padding, margin, and border. I am

Solution 1:

Sime Vidas pointed me in the right direction, so thanks!

I found myself trying to find out the exact height of the collapsed margins between divs and their children (but worded it much differently in my question). When accessing that information trough the DOM it will tell me style attributes of the parents and children, but it does not report the height of any collapsed margins.

So...the real answer to my question is NO. I have not been able to find a way to directly access the attribute of the collapsed margins.

What is just as good is taking the offsetTop attribute of my div, and finding the difference between the offsetTop attribute of the next Div. That gives the total height including final rendering of margins. To find the margins only, subtract the scrollHeight.

This may not work in all scenarios, but was more than enough for my purposes.

Post a Comment for "Outer Element Margin Not Equal To Inner Element Margin"