欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

关于CSS3 transition-property问题_html/css_WEB-ITnose

程序员文章站 2024-02-10 19:39:40
...
css3动画效果
.transition{
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
transition: all .5s ease;
}
这里我只想对transform属性生效如下:
-webkit-transform: translateX(20px);
需要怎么写啊?下面的写法没有生效啊!
-webkit-transition: transform .5s ease;


回复讨论(解决方案)

-webkit-transform
也要类似写法吧

div
{
transform: translate(50px,100px);
-ms-transform: translate(50px,100px); /* IE 9 */
-webkit-transform: translate(50px,100px); /* Safari and Chrome */
-o-transform: translate(50px,100px); /* Opera */
-moz-transform: translate(50px,100px); /* Firefox */
}


你似乎需要一个触发事件

CSS3 IE兼容代码在线转换 IE's CSS3 Transforms Translator
演示代码

.trans {    width: 100px;    height: 100px;    background-color: yellow;}.trans:hover {/* W3C CSS3 standard */  transform: translateX(20px);  /* Firefox */  -moz-transform: translateX(20px);  /* webkit (Chrome, Safari, mobile browsers, etc) */   -webkit-transform: translateX(20px);  /* Opera */  -o-transform: translateX(20px);  /* IE>=9 */  -ms-transform: translateX(20px);   /* IE8+ - must be on one line, unfortunately */    -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=0, M21=0, M22=1, SizingMethod='auto expand')";      /* IE6 and 7 */    filter: progid:DXImageTransform.Microsoft.Matrix(            M11=1,            M12=0,            M21=0,            M22=1,            SizingMethod='auto expand');   /*    * To make the transform-origin be the middle of    * the object.    Note: These numbers    * are approximations.  For more accurate results,    * use Internet Explorer with this tool.    */   margin-left: 7px;    margin-top: -3px;    }

演示更新版
加上了transition