<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>3d轮播图</title>
<style type="text/css">
body {
margin: 0;
background-color: black;
}
.view {
perspective: 3600px;
transform-origin:left;
}
img {
width: 500px;
}
.space3D {
transform-style: preserve-3d;
width: 500px;
position: relative;
margin: 200px auto;
}
.space3D div{
position: absolute;
}
.space3D div:nth-child(1){
transform: rotateY(0deg) translateZ(730px);
}
.space3D div:nth-child(2){
transform: rotateY(40deg) translateZ(730px);
}
.space3D div:nth-child(3){
transform: rotateY(80deg) translateZ(730px);
}
.space3D div:nth-child(4){
transform: rotateY(120deg) translateZ(730px);
}
.space3D div:nth-child(5){
transform: rotateY(160deg) translateZ(730px);
}
.space3D div:nth-child(6){
transform: rotateY(200deg) translateZ(730px);
}
.space3D div:nth-child(7){
transform: rotateY(240deg) translateZ(730px);
}
.space3D div:nth-child(8){
transform: rotateY(280deg) translateZ(730px);
}
.space3D div:nth-child(9){
transform: rotateY(320deg) translateZ(730px);
}
</style>
</head>
<body>
<div class="view">
<div class="space3D">
<div><img src="../images/lunbo14.png"></div>
<div><img src="../images/lunbo13.png"></div>
<div><img src="../images/lunbo12.png"></div>
<div><img src="../images/lunbo11.png"></div>
<div><img src="../images/lunbo9.png"></div>
<div><img src="../images/lunbo3.png"></div>
<div><img src="../images/lunbo8.png"></div>
<div><img src="../images/lunbo6.png"></div>
<div><img src="../images/lunbo5.png"></div>
</div>
</div>
</body>
<script type="text/javascript">
var view=document.getElementsByClassName('view');//获取观众席
var space3D=document.getElementsByClassName('space3D')[0];//获取舞台
var pictures=space3D.getElementsByTagName('div');//舞台表演人员
var index=0;
//for循环图片
for (var i = 0; i < pictures.length; i++) {
pictures[i].onclick=function() {
index++;
space3D.style.transition="transform 2s";
space3D.style.transform="rotateY("+40*index+"deg)";
}
}
</script>
</html>