css3 3D旋转立方体

css 

* {
    margin: 0;
    padding: 0;
    list-style: none;
}
body {
    background: url(img/timg.jpg) repeat;
    background-size: 100px 100px;
    text-align: center;
    color: #fff;
}
.container {
    width: 300px;
    height: 300px;
    margin: 50px auto;
    perspective: 1000px;   //景深
}
.container .cube{
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: all 2s;
}
.container .cube li{
    position: absolute;
    width: 100%;
    height: 100%;
    border: 5px solid rgba(255,255,255, .4);
}
.container .cube li img{
    width: 100%;
    height: 100%;
}
.container .cube li.img1{
    transform: rotateY(0deg) translateZ(150px);
}
.container .cube li.img2{
    transform: rotateX(180deg) translateZ(150px);
}
.container .cube li.img3{
    transform: rotateY(90deg) translateZ(150px);
}
.container .cube li.img4{
    transform: rotateY(-90deg) translateZ(150px);
}
.container .cube li.img5{
    transform: rotateX(90deg) translateZ(150px);
}
.container .cube li.img6{
    transform: rotateX(-90deg) translateZ(150px);
}

.cube.init {
    transform: translateZ(-200px) rotateX(-15deg) rotateY(18deg);
}


.btnArea {
    display: grid;
    grid-template-columns: 105px 105px 105px;
    grid-template-rows: 85px 85px;
    justify-content: center;
    grid-gap: 15px;
}
.btnArea input {
    width: 105px;
    height: 85px;
    outline: none;
    border: 2px solid #fff;

}
.btnArea input:focus {
    border: 2px solid darkblue;
}

.cube.show-image-1 {
    transform: translateZ(-200px) ;
}
.cube.show-image-2 {
    transform: translateZ(-200px) rotateX(-180deg);
}
.cube.show-image-3 {
    transform: translateZ(-200px) rotateY(-90deg);
}
.cube.show-image-4 {
    transform: translateZ(-200px) rotateY(90deg);
}

.cube.show-image-5 {
    transform: translateZ(-200px) rotateX(-90deg);
}

.cube.show-image-6 {
    transform: translateZ(-200px) rotateX(90deg);
}

html  javascript



    
        
        
        
    
    
        

点击下面图片旋转

 

你可能感兴趣的:(css3 3D旋转立方体)