<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>骰子</title>
<style type="text/css">
ul {
margin: 200px;
width: 200px;
height: 200px;
/*border: 2px solid black;*/
transform-style: preserve-3d;
animation: aaa 5s infinite;
}
li {
position: absolute;
height: 100px;
width: 100px;
/*border: solid 1px red;*/
list-style: none;
text-align: center;
line-height: 100px;
font-size: 2em;
color: white;
opacity: 0.5;
}
li:nth-of-type(1) {
background: red;
}
li:nth-of-type(2) {
background: yellow;
transform: rotateX(-90deg);
transform-origin: top;
}
li:nth-of-type(3) {
background: green;
transform: rotateY(90deg);
transform-origin: left;
}
li:nth-of-type(4) {
background: blue;
transform: rotateY(-90deg);
transform-origin: right;
}
li:nth-of-type(5) {
background: purple;
transform: rotateX(90deg);
transform-origin: bottom;
}
li:nth-of-type(6) {
background: orangered;
transform: translateZ(-100px);
}
@keyframes aaa {
0% {
transform: rotateX(0deg) rotateY(0deg);
}
100% {
transform: rotateX( 360deg) rotateY(360deg);
}
</style>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>骰子</title>
<style type="text/css">
ul {
margin: 200px;
width: 200px;
height: 200px;
/*border: 2px solid black;*/
transform-style: preserve-3d;
animation: aaa 5s infinite;
}
li {
position: absolute;
height: 100px;
width: 100px;
/*border: solid 1px red;*/
list-style: none;
text-align: center;
line-height: 100px;
font-size: 2em;
color: white;
opacity: 0.5;
}
li:nth-of-type(1) {
background: red;
}
li:nth-of-type(2) {
background: yellow;
transform: rotateX(-90deg);
transform-origin: top;
}
li:nth-of-type(3) {
background: green;
transform: rotateY(90deg);
transform-origin: left;
}
li:nth-of-type(4) {
background: blue;
transform: rotateY(-90deg);
transform-origin: right;
}
li:nth-of-type(5) {
background: purple;
transform: rotateX(90deg);
transform-origin: bottom;
}
li:nth-of-type(6) {
background: orangered;
transform: translateZ(-100px);
}
@keyframes aaa {
0% {
transform: rotateX(0deg) rotateY(0deg);
}
100% {
transform: rotateX( 360deg) rotateY(360deg);
}
</style>
</head>
<body>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</body>
</html>