在制作网站时避免图片太平淡经常会用到动画效果:由小到大跳跃出现。这种效果很有视觉冲击力,显著提高关注度~
原理:利用css3的动画属性@keyframes@-moz-keyframes@-webkit-keyframes定义动画suofang,再用animation调用suofang这一动画帧,并将动画添加到图片上,需要注意的是需要给图片相当于初始化的一个处理
transform:scale();
-moz-transform:scale();
-webkit-transform:scale();
最后在js中调用css动画。对于不同的页面,需要使用index来标注不同的页面。
<!--第二屏开始-->
<div class="section">
<div class="mdmobile-second-one">
<div class="mdmobile-second-one-top">
<img src="data:images/06_03.png" class="mdmobile-second-one-top-top"/>
<img src="data:images/06_07.png" class="mdmobile-second-one-top-foot"/>
</div> <div class="mdmobile-second-one-middle">
<div class="mdmobile-second-one-middle-top">
<img src="data:images/07_03.png" class="mdmobile-second-one-middle-top-left"/>
<img src="data:images/07_05.png" class="mdmobile-second-one-middle-top-right"/>
<div class="clear"></div>
</div>
<div class="mdmobile-second-one-middle-middle">
<img src="data:images/07_09.png" class="mdmobile-second-one-middle-middle-one"/>
<img src="data:images/07_11.png" class="mdmobile-second-one-middle-middle-two"/>
<img src="data:images/07_13.png" class="mdmobile-second-one-middle-middle-three"/>
<div class="clear"></div>
</div>
<div class="mdmobile-second-one-middle-foot">
<img src="data:images/07_16.png" class="mdmobile-second-one-middle-foot-left"/>
<img src="data:images/07_18.png" class="mdmobile-second-one-middle-foot-right"/>
<div class="clear"></div>
</div>
</div>
<div class="mdmobile-second-one-foot">
</div>
</div>
</div>
<!--第二屏结束-->
/*第二屏开始*/ @keyframes suofang {
% {transform:scale(0.2);}
% {transform:scale(1.0);}
}
@-moz-keyframes suofang {
% {-moz-transform:scale(0.2);}
% {-moz-transform:scale(1.0);}
}
@-webkit-keyframes suofang {
% {-webkit-transform:scale(0.2);}
% {-webkit-transform:scale(1.0);}
}
.mdmobile-second-one-middle-top-right.active,
.mdmobile-second-one-middle-top-left.active,
.mdmobile-second-one-middle-middle-one.active,
.mdmobile-second-one-middle-middle-two.active,
.mdmobile-second-one-middle-middle-three.active,
.mdmobile-second-one-middle-foot-left.active,
.mdmobile-second-one-middle-foot-right.active
{
animation: suofang 1s forwards;
-moz-animation: suofang 1s forwards;
-webkit-animation: suofang 1s forwards;
}
.mdmobile-second-one-middle-top-right,
.mdmobile-second-one-middle-top-left,
.mdmobile-second-one-middle-middle-one,
.mdmobile-second-one-middle-middle-two,
.mdmobile-second-one-middle-middle-three,
.mdmobile-second-one-middle-foot-left,
.mdmobile-second-one-middle-foot-right
{
transform:scale();
-moz-transform:scale();
-webkit-transform:scale();
}
if(index == ){
$(".mdmobile-second-one-middle-top-left").addClass("active");
setTimeout(function(){
$(".mdmobile-second-one-middle-top-right").addClass("active");
},);
setTimeout(function(){
$(".mdmobile-second-one-middle-middle-one").addClass("active");
},);
setTimeout(function(){
$(".mdmobile-second-one-middle-middle-two").addClass("active");
},);
setTimeout(function(){
$(".mdmobile-second-one-middle-middle-three").addClass("active");
},);
setTimeout(function(){
$(".mdmobile-second-one-middle-foot-left").addClass("active");
},);
setTimeout(function(){
$(".mdmobile-second-one-middle-foot-right").addClass("active");
},);
}