有没有办法只对一个变换函数进行动画处理?例如,我只想在缩放函数上进行过渡动画。我该怎么做?
.my-class {
transition: transform;
}
.large {
transform: scale(2) rotate(90deg);
}
<div class="my-class"></div>
<div class="my-class large"></div>
有没有办法只对一个变换函数进行动画处理?例如,我只想在缩放函数上进行过渡动画。我该怎么做?
.my-class {
transition: transform;
}
.large {
transform: scale(2) rotate(90deg);
}
<div class="my-class"></div>
<div class="my-class large"></div>
不要忘记
使用相应的浏览器支持引擎
使其正常工作。以下是各种浏览器支持的各种动画功能的列表。
http://css3.bradshawenterprises.com/support/
.my-class {
transition: transform;
}
.scale_and_rotate {
-webkit-transform: scale(2) rotate(90deg);
-moz-transform: scale(2) rotate(90deg);
-ms-transform: scale(2) rotate(90deg);
-o-transform: scale(2) rotate(90deg);
}
.scale_class {
-webkit-transform: scale(2); // Safari and Chrome(Engine:-Webkit)
-moz-transform: scale(2); // Mozilla(Engine:-Gecko)
-ms-transform: scale(2); // IE(Engine:-Trident)
-o-transform: scale(2); // Opera(Engine:-Presto)
}
.rotate_class {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
}
<div class="my-class"></div>
<div class="my-class scale_class"></div> // only scale function
<div class="my-class rotate_class"></div> // only rotate function
<div class="my-class scale_and_rotate"></div> // both scale and rotate function
请点击这里查看JSFiddle
如果你想同时进行缩放和旋转,那么你提供的类应该有效。
此外,你可以查看CSS的@keyframes
来实现这一点。以下是一些很好的教程。
https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes
http://coding.smashingmagazine.com/2011/05/17/an-introduction-to-css3-keyframe-animations/