html { padding:0; margin:0; background:linear-gradient(#06BCFD 0%,#005DE9 100%); height:100%; opacity:1; } .box { margin-top:200px; perspective:1000px; } .container { height:200px; width:200px; position:relative; margin:auto; transform-style:preserve-3d; animation:rotate 5s infinite linear; } @keyframes rotate { from { transform:rotate(0deg) rotateX(0deg); } to { transform:rotateY(360deg) rotateX(360deg); } }.container>div { height:100%; width:100%; opacity:1; position:absolute; text-align:center; background:#333; color:#fff; line-height:200px; font-size:30px; border:1px solid #fff; } .container>div>img { width:100%; height:100%; } .front { transform:translateZ(100px); } .back { transform:translateZ(-100px); } .left { transform:rotateY(90deg) translateZ(-100px); } .right { transform:rotateY(90deg) translateZ(100px); } .top { transform:rotateX(90deg) translateZ(100px); } .bottom { transform:rotateX(90deg) translateZ(-100px); }
此代码利用纯css3制作的一个3d旋转动画相册,代码简单易懂