Css achieves 3D cube Rotation effects and css 3D cube Effects
First, let's look at the effect after running.
It is a cube that keeps running.
First, let's look at the html code.
<Div class = "rect-wrap"> <! -- Stage element: Set the perspective to get the perspective effect for its child elements. --> <Div class = "container"> <! -- Container, set transform-style: preserve-3d to render its child elements in 3D space --> <div class = "top slide"> </div> <! -- Six cubes --> <div class = "bottom slide"> </div> <div class = "left slide"> </div> <div class = "right slide "> </div> <div class =" front slide "> </div> <div class =" back slide "> </div>>
Create six divs first, and then set styles for them in sequence.
Let's look at their style sheets.
<Style type = "text/css">. rect-wrap {position: relative; perspective: 1600px ;}. container {width: 800px; height: 800px; transform-style: preserve-3d; transform-origin: 50% 50% 200px; /* set the origin of the 3d space to move px from the center of the plane to the Z axis */}. slide {width: 400px; height: 400px; position: absolute; // positioning }. top {left: 200px; top:-200px; transform: rotateX (-90deg); transform-origin: bottom; background-color: # C69 }. bottom {left: 200px; bottom:-200px; transform: rotateX (90deg); transform-origin: top; background-color: # 6FF }. left {left:-200px; top: 200px; transform: rotateY (90deg); transform-origin: right; background-color: #9F0 }. right {left: 600px; top: 200px; transform: rotateY (-90deg); transform-origin: left; background-color: # 33F }. front {left: 200px; top: 200px; transform: translateZ (400px); background-color: #366/* the front of the cube is facing the screen, so no rotation is required, just move the distance to the front of the Z axis */}. back {left: 200px; top: 200px; transform: translateZ (0); background-color: # 09F/* The Cube is facing the screen, so you do not need to rotate it, just move the distance */} @ keyframes rotate-frame {0% {transform: rotateX (0deg) rotateY (0deg);} 10% {transform: rotateX (0deg) rotateY (180deg);} 20% {transform: rotateX (-180deg) rotateY (180deg);} 30% {transform: rotateX (-360deg) rotateY (180deg);} 40% {transform: rotateX (-360deg) rotateY (360deg);} 50% {transform: rotateX (-180deg) rotateY (360deg);} 60% {transform: rotateX (90deg) rotateY (180deg );} 70% {transform: rotateX (0) rotateY (180deg);} 80% {transform: rotateX (90deg) rotateY (90deg);} 90% {transform: rotateX (90deg) rotateY (0);} 100% {transform: rotateX (0) rotateY (0 );}}. container {animation: rotate-frame 30 s linear infinite;} </style>
Only these codes can be used for 3D Rotation.
It can also be converted into an image.
Add slices to each div, set each image to a uniform name, and then set a uniform style for them. set height and width.
You can paste and copy the code. Please try it all.