3D旋转立方体案例
Posted 萧诺
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3D旋转立方体案例相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CSS 3D转换</title> <style> body { margin: 0; padding: 0; background-color: #F7F7F7; } .box { width: 100px; height: 100px; text-align: center; line-height: 100px; font-size: 24px; margin: 100px auto; position: relative; transform: rotateY(30deg) rotateX(-30deg); transform-style: preserve-3d; /*perspective:200px;*/ animation: rotate 4s linear infinite; } .box div{ width: 200px; height: 200px; position: absolute; left: 0; top: 0; opacity: 0.6; } .front{ transform: translateZ(100px); background: pink; } .back{ transform: translateZ(-100px) rotateY(180deg); background: green; } .left{ transform: translateX(-100px) rotateY(-90deg); background: yellowgreen; } .right{ transform: translateX(100px) rotateY(90deg); background: blueviolet; } .top{ transform: translateY(-100px) rotateX(90deg); background: blue; } .bottom{ transform: translateY(100px) rotateX(-90deg); background: red; } @keyframes rotate { from{ transform: rotateY(30deg) rotateX(-30deg); } to{ transform: rotateY(390deg) rotateX(-30deg); } } </style> </head> <body> <div class="box"> <div class="front">front</div> <div class="back">back</div> <div class="left">left</div> <div class="right">right</div> <div class="top">top</div> <div class="bottom">bottom</div> </div> </body> </html>
以上是关于3D旋转立方体案例的主要内容,如果未能解决你的问题,请参考以下文章