我需要从窗口10%
中减去height/2
,但没有结果,问题是什么?
var loadingMargin = $(window).height()/2;
$(".loading .sk-circle").animate({
marginTop: loadingMargin-10+"%"
});
答案 0 :(得分:1)
计算90
百分比并设置值
var loadingMargin = ($(window).height() / 2) * .9;
$(".loading .sk-circle").animate({
marginTop: loadingMargin
});
答案 1 :(得分:0)
你甚至可以尝试这样做,
var loadingMargin = ($(window).height())/2, //window Height /2
calMargin = loadingMargin*0.1, //10% of window height
substractVal = (loadingMargin - calMargin); //substract value
$(".loading .sk-circle").animate({
marginTop : substractVal
});