效果
<!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;
margin: 0;
}
html,
body {
width: 100%;
height: 100%;
background: #000;
color: #D5D6E2;
font-weight: 500;
font-size: 1.05em;
}
.htmleaf-container {
margin: 0 auto;
}
#trans3DDemo1 {
position: relative;
display: inline-block;
width: 250px;
height: 250px;
top: 300px;
left: 50%;
}
#trans3DBoxes1 {
transform-style: preserve-3d;
perspective: 3000px;
transform: translate(120px) rotate3d(1, 1, 1, -41deg);
}
#trans3DBoxes1 div {
position: absolute;
width: 248px;
height: 248px;
padding: 0;
margin: 0;
border: 1px solid rgba(255, 255, 255, .2);
display: block;
text-align: center;
font-size: 36px;
font-weight: bold;
}
.a1 {
background: rgb(148, 141, 131);
opacity: 0.85;
transform:matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,125,1);
或者
translate3d(0px, 0px, 125px)
}
.a2 {
background: rgb(10, 59, 110);
opacity: 0.85;
transform: matrix3d(0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, -125, 0, 0, 1);
或者
translate3d(-125px, 0px, 0px) rotate3d(0, 1, 0, -90deg)
}
.a3 {
background: rgb(70, 179, 24);
opacity: 0.85;
transform: matrix3d(0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 125, 0, 0, 1);
或者
translate3d(125px, 0px, 0px) rotate3d(0, 1, 0, 90deg)
}
.a4 {
background: rgb(237, 190, 2);
opacity: 0.85;
transform: matrix3d(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, -125, 0, 1);
或者
translate3d(0, -125px, 0) rotate3d(1, 0, 0, 90deg)
}
.a5 {
background: rgb(199, 118, 19);
opacity: 0.85;
transform: matrix3d(1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 125, 0, 1);
}
.a6 {
background: rgb(184, 33, 36);
opacity: 0.85;
transform: matrix3d(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, -125, 1);
}
</style>
</head>
<body>
<div id="trans3DDemo1">
<div id="trans3DBoxes1">
<div class="a1">Front</div>
<div class="a2">Left</div>
<div class="a3">Right</div>
<div class="a4">Top</div>
<div class="a5">Bottom</div>
<div class="a6">Back</div>
</div>
</div>
</body>
</html>