按顺序做上 后 下 前 左 右
- 上 : x轴旋转90度 , z轴正向偏移100px
- 后 : x轴旋转180度 , z轴正向偏移100px
- 下 : x轴旋转270度 , z轴正向偏移100px
- 前 : x轴旋转360度 , z轴正向偏移100px
- 左 : x轴负向偏移100px , y轴旋转90度
- 右 : x轴正向偏移100px , y轴旋转90度
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
width: 0;
}
div {
position: relative;
width: 200px;
height: 200px;
}
ul {
position: absolute;
left: 400px;
top: 200px;
width: 200px;
height: 200px;
list-style: none;
/* border: 1px solid #000;
box-sizing: border-box; */
transform: rotateY(0deg) rotateX(0deg);
transform-style: preserve-3d;
}
li {
position: absolute;
left: 0;
top: 0;
width: 200px;
height: 200px;
font-size: 60px;
line-height: 200px;
text-align: center;
}
/* 核心代码 */
li:nth-child(1) {
background-color: rgb(163, 99, 99);
transform: rotateX(90deg) translateZ(100px);
}
li:nth-child(2) {
background-color: rgb(238, 217, 28);
transform: rotateX(180deg) translateZ(100px);
}
li:nth-child(3) {
background-color: rgb(233, 70, 151);
transform: rotateX(270deg) translateZ(100px);
}
li:nth-child(4) {
background-color: rgb(107, 47, 218);
transform: rotateX(360deg) translateZ(100px);
}
li:nth-child(5) {
background-color: rgb(29, 61, 240);
transform: translateX(-100px) rotateY(90deg);
}
li:nth-child(6) {
background-color: rgb(58, 228, 134);
transform: translateX(100px) rotateY(90deg);
}
</style>
</head>
<body>
<div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</div>
</body>
</html>