简体   繁体   English

CSS3用scaleX和scaleY设置动画吗?

[英]css3 animate with scaleX and scaleY?

Well here what i want, i need to scale and move! 好吧,在这里我想要什么,我需要扩展和移动! an object at the same time, now i have something like this: 一个对象在同一时间,现在我有这样的事情:

element.addClass('scale').animate({
     top:  pxToMove.top+"px",
     left: pxToMove.left+"px"
},1000});

and the scale class goes like: 比例尺类如下:

-webkit-transform: scaleX(1.8) scaleY(1.8);
-o-transform: scaleX(1.8) scaleY(1.8);
-moz-transform: scaleX(1.8) scaleY(1.8);
transform: scaleX(1.8) scaleY(1.8);

So first the scaling is happening and then the object moves, how can i do them simultaneously? 因此,首先发生缩放,然后对象移动,我如何同时执行它们?

you can also do a pure css solution as such: 您也可以这样做一个纯CSS解决方案:

CSS: CSS:

@keyframes scale-move {
  0%   { transform: translate(0,0) scale(1,1); }
  100% { transform: translate(500px,250px) scale(5,5); }
}

#move {
  animation: scale-move 10s infinite;
}

Fiddle Me This... (Not vendor prefixed... working in FF only ATM) 弄弄我这个... (没有供应商前缀...仅在FF ATM中工作)

Spare yourself for re-inventing the wheel and take advantage of a already-written library; 腾出时间重新发明轮子,并利用已经编写的库; jQuery transit . jQuery运输 You can CSS3 animate pretty much any property! 您几乎可以对CSS3进行任何属性的动画设置! :-) :-)

It's as easy as: 就像这样简单:

element.transition({top: pxToMove.top, left: pxToMove.left, scale:1.8}, 1000);

Of course this applies if you are animating a lot of stuff on your site; 当然,如果您要在网站上制作很多动画,这也适用; including that piece of library for just one animation is over-kill. 仅将其中一个动画包括在该库中就太过致命了。 But as of sites today, you are most likely to use it more than once. 但是从今天的站点来看,您最有可能多次使用它。

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

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