|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 5 | +<title>无标题文档</title> |
| 6 | +<style id="css"> |
| 7 | +body,ul,ol{ margin:0;padding:0; list-style:none;} |
| 8 | +.box{width:800px; margin:50px auto; |
| 9 | +} |
| 10 | +.picList{ width:800px;height:360px;-webkit-perspective:800px; } |
| 11 | +.picList li{ width:25px;height:360px;float:left;position:relative;-webkit-transform-style:preserve-3d; -webkit-transform:translateZ(-180px);} |
| 12 | +.picList a{ width:100%; height:360px; position:absolute; left:0;top:0;} |
| 13 | +.picList span{ width:360px;height:360px; background:#333; position:absolute; top:0;} |
| 14 | +.picList li a:nth-of-type(1){ background:url(img/1.jpg) no-repeat; -webkit-transform:translateZ(180px);} |
| 15 | +.picList li a:nth-of-type(2){ background:url(img/2.jpg) no-repeat; -webkit-transform:translateZ(-180px) rotateX(90deg); -webkit-transform-origin:top;} |
| 16 | +.picList li a:nth-of-type(3){ background:url(img/3.jpg) no-repeat;-webkit-transform:translateZ(-180px) rotateX(180deg);} |
| 17 | +.picList li a:nth-of-type(4){ background:url(img/4.jpg) no-repeat;-webkit-transform-origin:bottom;-webkit-transform: translateZ(-180px) rotateX(-90deg);} |
| 18 | +.picList li span:nth-of-type(1){ left:0; -webkit-transform-origin:left;-webkit-transform:translateZ(180px) rotateY(90deg);} |
| 19 | +.picList li span:nth-of-type(2){right:0; -webkit-transform-origin:right;-webkit-transform:translateZ(180px) rotateY(-90deg);} |
| 20 | +#btn{padding:50px; height:30px;} |
| 21 | +#btn li{ width:30px;height:30px; background:#000; color:#fff; font:bold 16px/30px Arial; text-align:center; float:left; margin:0 10px; border-radius:50%;} |
| 22 | +#btn .active{ background:#f60;} |
| 23 | +</style> |
| 24 | +<script> |
| 25 | +window.onload=function() |
| 26 | +{ |
| 27 | + var oPic=document.getElementById("pic"); |
| 28 | + var oCss=document.getElementById("css"); |
| 29 | + var aBtn=document.getElementById("btn").getElementsByTagName("li"); |
| 30 | + var iLiW=25; |
| 31 | + var iLength=oPic.clientWidth/iLiW; |
| 32 | + var aLi=[]; |
| 33 | + var sHtml=""; |
| 34 | + var sCss=""; |
| 35 | + var iZindex=0; |
| 36 | + var iNow=0; |
| 37 | + for(var i=0;i<iLength;i++) |
| 38 | + { |
| 39 | + i>iLength/2?iZindex--:iZindex++; |
| 40 | + sCss+=".picList li:nth-of-type("+(i+1)+"){z-index:"+iZindex+";}.picList li:nth-of-type("+(i+1)+") a{background-position:-"+i*iLiW+"px 0px;}" |
| 41 | + } |
| 42 | + oCss.innerHTML+=sCss; |
| 43 | + for(var i=0;i<iLength;i++) |
| 44 | + { |
| 45 | + sHtml+='<li><a href="#"></a><a href="#"></a><a href="#"></a><a href="#"></a><span></span><span></span></li>'; |
| 46 | + } |
| 47 | + oPic.innerHTML=sHtml; |
| 48 | + aLi=oPic.getElementsByTagName("li"); |
| 49 | + for(var i=0;i<aBtn.length;i++) |
| 50 | + { |
| 51 | + aBtn[i].onclick=(function(a){ |
| 52 | + return function() |
| 53 | + { |
| 54 | + aBtn[iNow].className=""; |
| 55 | + for(var i=0;i<aLi.length;i++) |
| 56 | + { |
| 57 | + aLi[i].style.transition=Math.abs(a-iNow)*0.5+"s "+i*80+"ms all ease"; |
| 58 | + aLi[i].style.WebkitTransform="translateZ(-180px) rotateX(-"+a*90+"deg)"; |
| 59 | + } |
| 60 | + iNow=a; |
| 61 | + aBtn[iNow].className="active"; |
| 62 | + }; |
| 63 | + })(i); |
| 64 | + } |
| 65 | +} |
| 66 | +</script> |
| 67 | +</head> |
| 68 | +<body> |
| 69 | +<div class="box"> |
| 70 | + <ul class="picList" id="pic"> |
| 71 | + |
| 72 | + </ul> |
| 73 | + <ol id="btn"> |
| 74 | + <li class="active">1</li> |
| 75 | + <li>2</li> |
| 76 | + <li>3</li> |
| 77 | + <li>4</li> |
| 78 | + </ol> |
| 79 | +</div> |
| 80 | +</body> |
| 81 | +</html> |
0 commit comments