其实css3有两种方式实现这个效果:
1. css3 过度transition
.class{
position:relative;
-webkit-transition: top 10s linear; /*top 时间(用秒计算)s linear;*/
-moz-transition: top 10s linear;
-o-transition: top 10s linear;
transition: top 10s linear;
}
.class:hover{
top:100px;
}
详见:http://www.w3school.com.cn/css3/css3_transition.asp
2. css3 动画animation
@-webkit-keyframes myfirst{
from {top: 0;}
to {top: 100px;}
}
@-moz-keyframes myfirst{
from {top: 0;}
to {top: 100px;}
}
@-o-keyframes myfirst{
from {top: 0;}
to {top: 100px;}
}
@keyframes myfirst{
from {top: 0;}
to {top: 100px;}
}
.class{
position:relative;
}
.class:hover{
-webkit-animation:myfirst 10s;
-moz-animation:myfirst 10s;
-o-animation:myfirst 10s;
animation:myfirst 10s;
}
详见:http://www.w3school.com.cn/css3/css3_animation.asp