1919 left : 50% ;
2020 margin-top : 200px ;
2121 font-size : 3rem ;
22- perspective : 1000 px ;
22+ perspective : 2000 px ;
2323 perspective-origin : 0 150px ;
24+ transform-style : preserve-3d;
2425 }
2526
2627 .side {
28+ transition-duration : 3s ;
2729 height : 300px ;
2830 width : 300px ;
2931 border : 5px solid rgba (0 , 0 , 0 , .3 );
@@ -47,32 +49,55 @@ <h1>3D 正方体组合旋转</h1>
4749 < style type ="text/css ">
4850 .top {
4951 animation : placeTop 1s linear both;
50- /*animation-name: placeTop, rotateTop;
51- animation-timing-function: linear;
52- animation-duration: 2s;
53- animation-delay: 0s, 12s;
54- animation-iteration-count: 1, infinite;
55- animation-fill-mode: both;*/
52+ transition-property : background-color;
5653 }
5754
5855 .bottom {
5956 animation : placeBottom 1s 1s linear both;
57+ transition-property : background-color;
6058 }
6159
6260 .left {
6361 animation : placeLeft 1s 2s linear both;
62+ transition-property : background-color;
6463 }
6564
6665 .right {
6766 animation : placeRight 1s 3s linear both;
67+ transition-property : background-color;
6868 }
6969
7070 .back {
7171 animation : placeBack 1s 4s linear both;
72+ transition-property : background-color;
7273 }
7374
7475 .front {
7576 animation : placeFront 1s 5s linear both;
77+ transition-property : background-color;
78+ }
79+
80+ .container {
81+ animation : cube 3s 6s linear infinite both;
82+ }
83+
84+ .container : hover .top {
85+ background-color : red;
86+ }
87+ .container : hover .bottom {
88+ background-color : green;
89+ }
90+ .container : hover .left {
91+ background-color : blue;
92+ }
93+ .container : hover .right {
94+ background-color : yellow;
95+ }
96+ .container : hover .back {
97+ background-color : gray;
98+ }
99+ .container : hover .front {
100+ background-color : orange;
76101 }
77102
78103 @keyframes placeTop {
@@ -110,6 +135,16 @@ <h1>3D 正方体组合旋转</h1>
110135 transform : translateZ (150px );
111136 }
112137 }
138+
139+ @-webkit-keyframes cube {
140+ 0% {
141+ perspective : 2000px ;
142+ }
143+ 100% {
144+ perspective : 0px ;
145+ transform : rotate3d (0.5 , 0.5 , 0.5 , 360deg );
146+ }
147+ }
113148 </ style >
114149</ body >
115150
0 commit comments