user3879222 user3879222 - 2 years ago 134
jQuery Question

Margin top calculations in animate jquery

I need to subtract

10%
from the window
height/2
but with no result , what is the problem ?

var loadingMargin = $(window).height()/2;
$(".loading .sk-circle").animate({
marginTop: loadingMargin-10+"%"
});

Answer Source

Calculate 90percentage and set value

var loadingMargin = ($(window).height() / 2) * .9;
$(".loading .sk-circle").animate({
  marginTop: loadingMargin
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download