[英]How to transition only rotate transformation?
我正在使用一堆元素来构图背景图像,它们都绝对定位,自由旋转。
问题是,我想只转换那些对象的旋转,而不是顶部或左边的属性。 显然是transition: transform 30s;
是不允许的。 我有很棒的想法
transition:all 30s ease-out;
transition: left 0s;
transition: top 0s;
但这也行不通。 我怎么解决这个问题?
Transform是供应商前缀
代替
transition:all 30s ease-out;
transition: left 0s;
transition: top 0s;
做
-webkit-transition: -webkit-transform $amount-of-time ease-out;
-moz-transition: -moz-transform $amount-of-time ease-out;
-o-transition: -o-transform $amount-of-time ease-out;
-ms-transition: -ms-transform $amount-of-time ease-out;
transition: transform $amount-of-time ease-out;
要仅为旋转属性设置动画,我发现这至少可以在Chrome中使用:
transition: transform 2.0s;
您可以为一个转换属性中的不同属性设置不同的动画时间:
transition: transform 2.0s, color 5.0s, font-size 1.0s;
具有rotate
属性的技巧特别是你使用了transform
属性。 直觉上,这应该工作,但不起作用:
transition: rotate 2.0s; /* DOES NOT WORK */
相反,你必须使用transform
代替rotate
:
transition: transform 2.0s;
这可能是因为rotate: 90deg
是transform: rotate(90deg)
简写transform: rotate(90deg)
现在,所有主流浏览器的最新版本都支持transition
。 我假设如果您想要与旧浏览器更兼容,您可能会执行以下操作:
-webkit-transition: -webkit-transform 2.0s, color 5.0s, font-size 1.0s;
-moz-transition: -moz-transform 2.0s, color 5.0s, font-size 1.0s;
-ms-transition: -ms-transform 2.0s, color 5.0s, font-size 1.0s;
-o-transition: -o-transform 2.0s, color 5.0s, font-size 1.0s;
transition: transform 2.0s, color 5.0s, font-size 1.0s;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.