<!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>
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
}
body {
display: flex;
justify-content: center;
align-items: center;
perspective: 1000px;
background: linear-gradient(pink, purple);
}
div {
width: 300px;
height: 300px;
/* border: 1px solid #333; */
position: relative;
transform-style: preserve-3d;
transition: transform 10s;
/* 动画:动画名称 动画时间 动画类型 动画播放次数 */
animation: play 5s infinite;
}
p {
width: 300px;
height: 300px;
border: 2px double #333;
box-sizing: border-box;
font: 100 40px/300px "";
color: #333;
text-align: center;
position: absolute;
background: rgba(255, 255, 255, .3);
}
p:nth-child(1) {
transform: translateY(-150px) rotateX(90deg);
}
p:nth-child(2) {
transform: translateY(150px) rotateX(-90deg);
}
p:nth-child(3) {
transform: translateX(-150px) rotateY(-90deg);
}
p:nth-child(4) {
transform: translateX(150px) rotateY(90deg);
}
p:nth-child(5) {
transform: translateZ(150px);
}
p:nth-child(6) {
transform: translateZ(-150px) rotateY(180deg);
}
div:hover {
transform: rotateX(240deg) rotateY(240deg);
}
@keyframes play {
100% {
transform: rotateY(360deg);
}
}
</style>
</head>
<body>
<div>
<p>p1</p>
<p>p2</p>
<p>p3</p>
<p>p4</p>
<p>p5</p>
<p>p6</p>
</div>
</body>
</html>