how to animate marginTop of a div with click -


i want animate div marign-top property.initially set margin-top:10%.on click reduce margin-top 5% , reveals next div content(with toggle()).

#login { margin:10% auto; ...... }   $("#login").click(function() {      $( "#outer_wrapper" ).toggle( "clip",300);   $("#login").animate({margintop:'5%'}); } 

that works fine.but how initial "margin-top:10%" when clicked "#login" again?

in css3, can common animation transition properties. example

.test{    -webkit-transition: .5s ease;    -moz-transition: .5s ease; } 

and directly set margin top style of element (as using jquery)

$('.test').css('margin-top','5%'); 

then apply animation automatically. 'linear' animation can take effect on css changes such width, height, background color, etc.


Comments

Popular posts from this blog

c++ - End of file on pipe magic during open -

basic authentication with http post params android -

data.table making a copy of table in R -