简体   繁体   English

更改旋转动画位置

[英]Change rotate animation position

I am trying to implement rotate animation its working but I want to change the div position. 我正在尝试实现旋转动画的工作,但是我想更改div的位置。 Here is my code:- 这是我的代码:

$(function(){
var el=$('div');
el.animate({ deg: 180 }, {
            duration: 1000,
            step: function (now) {
                el.css({
                    transform: 'rotate(' + now + 'deg)'
                });
            },
            complete: function () {                    
     },
  });
});

Fiddle Demo 小提琴演示

I want this position(now its first but I want second):- 我想要这个职位(现在是第一个,但我想第二个):

在此处输入图片说明

Thanks for your hepl 谢谢你的帮助

Use translateY(-100%) 使用translateY(-100%)

$(function(){
var el=$('div');
 el.animate({ deg: 180 }, {
                duration: 1000,
                step: function (now) {
                    el.css({
                        transform: 'rotate(' + now + 'deg) translateY(-100%)'
                    });
                },
                complete: function () {

         },
   });
});

DEMO DEMO

    $(function(){
    var el=$('div');
var topik = $('div').css('top');
    el.animate({ deg: 180 }, {
                duration: 1000,
                step: function (now) {
                    el.css({
                        transform: 'rotate(' + now + 'deg)',
                        top : topik+'500px',
    });
                },
                complete: function () {                    
         },
      });
    })

Dont thank me ;););) 不用谢我;););)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM