user3879222 user3879222 - 1 year ago 116
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
});