javascript - Issue with jQuery .animate command -


i using animate command jquery , reason doesn't work:

$('#my_div_id').animate({left:'calc(50% + 50px)'}, 1000); 

is there way around this?

i know code works if put '50%', or '50px', want div animate 50% of screen + 50px.

thanks in advance!

it seem calc cannot animated, fortunately it's easy calculate 50% of width of screen since have power of javascript.

$("#my_div_id").animate({left: $("body").width() / 2 + 50 + "px"}, 1000); 

this assumes #my_div_id positioned relative body (i.e. no relative position ancestory -- otherwise have use that).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -