赞
踩
- <div class="container">
- <div class="cube">
- <div class="side front">前面</div>
- <div class="side back">后面</div>
- <div class="side top">顶部</div>
- <div class="side bottom">底部</div>
- <div class="side left">左侧</div>
- <div class="side right">右侧</div>
- </div>
- </div>
- .side {
- position: absolute;
- width: 200px;
- height: 200px;
- background-color: rgba(190, 54, 23, 0.8);
- border: 1px solid #3a13d5;
- }
- .container {
- margin-top: 200px;
- margin-left: 200px;
- perspective: 1000px;
- .cube {
- width: 200px;
- height: 200px;
- position: relative;
- transform-style: preserve-3d;
- animation: spin 5s infinite linear;
- }
- .front {
- transform: translateZ(100px);
- }
-
- .back {
- transform: rotateY(180deg) translateZ(100px);
- }
-
- .top {
- transform: rotateX(90deg) translateZ(100px);
- }
-
- .bottom {
- transform: rotateX(-90deg) translateZ(100px);
- }
-
- .left {
- transform: rotateY(-90deg) translateZ(100px);
- }
-
- .right {
- transform: rotateY(90deg) translateZ(100px);
- }
5.用动画keyframes让其旋转起来:
- @keyframes spin {
- 0% {
- transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
- }
- 100% {
- transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。