<style>
* {
margin: 0;
padding: 0;
list-style: none;
box-sizing: border-box;
}
.box {
margin: 20px auto;
width: 100px;
height: 100px;
background-color: aqua;
position: relative;
transition: all 2s ease;
transform-style: preserve-3d;
}
.box div {
width: 100px;
height: 100px;
position: absolute;
left: 0px;
top: 0px;
text-align: center;
line-height: 100px;
font-size: 40px;
}
.box:hover{
transform: rotateX(360deg) rotateY(360deg);
}
.top {
transform: translatey(-100px) rotateX(90deg);
transform-origin: center bottom;
background-color: rgba(255, 0, 0, 0.8);
}
.bottom {
background-color: rgba(0, 0, 0, 0.8);
transform: translatey(100px) rotateX(-90deg);
transform-origin: center top;
}
.left {
background-color: rgba(0, 255, 0, 0.8);
transform: translateX(-100px) rotateY(-90deg);
transform-origin: right center;
}
.right {
background-color: rgba(0, 0, 255, 0.8);
transform: translateX(100px) rotateY(90deg);
transform-origin: left center;
}
.before {
background-color: rgba(255, 255, 0, 0.5);
z-index: 10;
}
.back {
background-color: rgba(255, 0, 255, 0.8);
transform: translateZ(-100px);
}
</style>