Why is this not working? Tearing off my hearing ...
This fiddle was updated with the approved answer
http://jsfiddle.net/jbreezy/pswdn2wb/
$(document).ready(function() {
var marginFix = $('.marginFix').css('font-size');
var onethirdMargin = parseInt(marginFix / 3);
$('.marginFix').css({"margin-top":marginFix});
$('.marginFix').css({"margin-bottom":onethirdMargin});
});
As you can see there, I just want the 'onethirdMargin' variable to be 1/3 of the other variable.
So, regardless of the fact that you have ever set the font size in css, the margin-top elements will be equal to the specified font size, and the edge of the field will be 1/3 of this automatically (If you apply the marginFix class to it). Currently, the bottom margin is still equal ... Any help is much appreciated!
source
share