以下是 jquery+css3单反转动镜头景物效果 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery+css3单反转动镜头景物效果</title>
<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<style type="text/css">
.bg{position:relative;width:293px;height:220px;background:url(img/camera.jpg);margin:100px auto;}
.beauty{width:120px;height:92px;text-align:center;position:absolute;left:54px;top:92px;}
.Dbeauty{visibility:hidden;}
.current.Dbeauty{
visibility:visible;position:absolute;top:0;left:0;
-webkit-animation:opacityChange 5s .5s linear both;
-moz-animation:opacityChange 5s .5s linear both;
}
.rotate{width:63px;height:63px;position:absolute;left:178px;top:114px;cursor:pointer;}
.current.rotate{
-webkit-animation:Rotate 7s ease forwards;
-moz-animation:Rotate 5s ease forwards;
}
@-webkit-keyframes Rotate{
0%{
-webkit-transform-origin:center;
-webkit-transform:rotate(0);
}
100%{
-webkit-transform-origin:center;
-webkit-transform:rotate(360deg);
}
}
@-moz-keyframes Rotate{
0%{
-moz-transform-origin:center center;
-moz-transform:rotate(0deg);
opacity:0
}
100%{
-moz-transform-origin:center center;
-moz-transform:rotate(360deg);
opacity:1;
}
}
@-webkit-keyframes opacityChange{
0%{
-webkit-transform-origin:center;
-webkit-transform:scale(0);
opacity:0;
}
100%{
-webkit-transform-origin:center;
-webkit-transform:scale(1);
opacity:1;
}
}
@-moz-keyframes opacityChange{
0%{
-moz-transform-origin:center;
-moz-transform:scale(0);
opacity:0;
}
100%{
opacity:1;
-moz-transform-origin:center;
-moz-transform:scale(1);
}
}
</style>
</head>
<body>
<div class="bg">
<div class="rotate"><img src="img/camera.png"/></div>
<div class="beauty"><img class="Dbeauty"src="img/beauty.jpg"/></div>
</div>
<script type="text/javascript">
$(function(){
$(".rotate").click(function(){
if($(".rotate").attr('class').indexOf("current")!=-1){
$(".rotate").removeClass('current')
$(".Dbeauty").removeClass('current')
setTimeout(function() {
$(".rotate").addClass("current");
$(".Dbeauty").addClass("current");
}, 10);
}else{
$(".rotate").addClass("current");
$(".Dbeauty").addClass("current");
}
})
})
</script>
</body>
</html>