Final Effect
Demo
Code
<! DOCTYPE html><Html><Headlang="EN" ><Metacharset="UTF-8" ><Title> Cube</Title><Style>*{Margin0;Padding0;}. stage{position:relative;Margin300px00300px;Perspective:800px;Width200px;Height200px;}. container{Width200px;Height200px;Position:absolute;transform-style:preserve-3d;Transition:all3s;}. face{Width100%;Height100%;Position:absolute;Left0;Top0;Text-align:center;Line-height:200px;Font-size:50px;Color#fff;Border1px solid#ccc;Opacity0.3;Background#999;}. f1{TransformRotatex (90DEG)Translatez (100px);}. f2{TransformTranslatez ( -100px);}. f3{TransformRotatex (90DEG)Translatez ( -100px);}. f4{TransformTranslatez (100px);}. f5{TransformRotatey (90DEG)Translatez (100px);}. f6{TransformRotatey (90DEG)Translatez ( -100px);}</Style></Head><Body><Button> rotation</Button><Div><Div><Div>1</Div><Div>2</Div><Div>3</Div><Div>4</Div><Div>5</Div><Div>6</Div></Div></div> < Script> var btn = document.getElementById (var cont = document.getelementbyid ( cont '); Btn.addeventlistener ( ' click ', function ( ' Rotatey (180deg) ';},false); </script></ body></HTML>
First we need a stage to set perspective (pivot value)
Then we need a container to do the rotation of the container, on the container above we need to set the Transfor-style, convenient container The following sub-elements into 3d elements.
Then we can start arranging positions for face.
Attach a coordinate chart for easy understanding
Coordinate Chart
CSS3 Implementation Cube