<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html {
perspective: 800;
}
.cube {
position: absolute;
top: 20%;
left: 20%;
width: 200px;
height: 200px;
box-sizing: border-box;
transform-style: preserve-3d;
animation: animate 20s infinite linear;
}
.cube:hover .img1 {
width: 300px;
height: 300px;
transform: rotateY(90deg) translateZ(200px);
}
.cube:hover .img2 {
width: 300px;
height: 300px;
transform: rotateY(-90deg) translateZ(200px);
}
.cube:hover .img3 {
width: 300px;
height: 300px;
transform: rotateX(90deg) translateZ(200px);
}
.cube:hover .img4 {
width: 300px;
height: 300px;
transform: rotateX(-90deg) translateZ(200px);
}
.cube:hover .img5 {
width: 300px;
height: 300px;
transform: translateZ(200px);
}
.cube:hover .img6 {
width: 300px;
height: 300px;
transform: rotateY(-180deg) translateZ(200px);
}
img {
transition: all .5s;
position: absolute;
opacity: .7;
}
.img1 {
transform: rotateY(90deg) translateZ(100px);
}
.img2 {
transform: rotateY(-90deg) translateZ(100px);
}
.img3 {
transform: rotateX(90deg) translateZ(100px);
}
.img4 {
transform: rotateX(-90deg) translateZ(100px);
}
.img5 {
transform: translateZ(100px);
}
.img6 {
transform: rotateY(-180deg) translateZ(100px);
}
@keyframes animate {
from {
transform: rotateX(0deg) rotateZ(0);
}
to {
transform: rotateX(1turn) rotateZ(1turn);
}
}
</style>
</head>
<body>
<div class="cube">
<img src="../images/1.jpg" class="img1" width="200" height="200" alt="">
<img src="../images/2.jpg" class="img2" width="200" height="200" alt="">
<img src="../images/3.jpg" class="img3" width="200" height="200" alt="">
<img src="../images/4.jpg" class="img4" width="200" height="200" alt="">
<img src="../images/5.jpg" class="img5" width="200" height="200" alt="">
<img src="../images/6.jpg" class="img6" width="200" height="200" alt="">
</div>
</body>
</html>