<!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>旋转的立方体</title>
<style>
/* 定义关键帧动画 */
/* @keyframes 动画名 {
关键帧
} */
@keyframes roll {
from {
transform: rotateX(0) rotateY(0) rotateZ(0);
}
to {
transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
}
}
* {
margin: 0;
padding: 0;
}
div {
width: 700px;
height: 700px;
background-color: skyblue;
line-height: 700px;
text-align: center;
color: white;
font-size: 100px;
position: absolute;
}
.wrap {
padding: 100px;
background-color: transparent;
transform-style: preserve-3d; /*开启3D效果*/
/* animation: 动画名 动画执行时间 [动画延迟时间 动画运动曲线 运动次数 是否反向执行 是否保留最后一帧] */
animation: roll 8s linear infinite;
}
.wrap div:nth-of-type(1) {
transform: rotateY(-90deg) translateZ(350px);
}
.wrap div:nth-of-type(2) {
transform: rotateY(90deg) translateZ(350px);
background-color: tomato;
}
.wrap div:nth-of-type(3) {
transform: rotateX(90deg) translateZ(350px);
background-color: plum;
}
.wrap div:nth-of-type(4) {
transform: rotateX(-90deg) translateZ(350px);
background-color: greenyellow;
}
.wrap div:nth-of-type(5) {
transform: translateZ(350px);
background-color: gold;
}
.wrap div:nth-of-type(6) {
transform: rotateX(180deg) translateZ(350px);
background-color: hotpink;
}
</style>
</head>
<body>
<div class="wrap">
<!-- 左右 -->
<div> <img src="https://img0.baidu.com/it/u=1317345167,3263672675&fm=26&fmt=auto" alt=""></div>
<div><img src="https://img0.baidu.com/it/u=3960377588,610015154&fm=26&fmt=auto" alt=""></div>
<!-- 上下 -->
<div><img src="https://img0.baidu.com/it/u=3705878594,1682381414&fm=26&fmt=auto" alt=""></div>
<div><img src="https://img2.baidu.com/it/u=2358024181,3036462462&fm=26&fmt=auto" alt=""></div>
<!-- 前后 -->
<div><img src="https://img2.baidu.com/it/u=1357183913,1047974800&fm=253&fmt=auto&app=120&f=JPEG?w=640&h=364" alt=""></div>
<div><img src="https://img2.baidu.com/it/u=2420135615,1341578679&fm=253&fmt=auto&app=120&f=JPEG?w=570&h=228" alt=""></div>
</div>
</body>
</html>