I'm trying to determine the used value of the margins of an element. My understanding is that this should be returned via .getComputedStyle(). However, it seems that FireFox and Opera don't return the correct values when margin: auto;
is used. Firefox returns '0px'
, and Opera returns '0px'
or, occasionally, 'auto'
:
http://jsfiddle.net/8FXbZ/
I know I could calculate the content width of the parent, and the total width of the child, and use those to calculate the margins, BUT I'm primarily looking at the case when the parent is a flexbox:
http://jsfiddle.net/8FXbZ/1/
Again, the values could possibly be 'reverse-engineered' but that would get relatively complicated (especially if the flexbox has wrapping allowed), so I was wondering if anyone had any other thoughts?
There is a bug in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=381328 that returns the wrong value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With