css实例正方体

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="index.css">
<style>
html,body{
height: 100%;
}
.main{
width: 300px;
height: 300px;
/ background-color: green; /
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
transform-style: preserve-3d;
/ transition: 20s; /
/ transform: rotateX(-35deg) rotateY(45deg) ; /
transform: rotateX(-15deg) rotateY(60deg) ;
}
.box{
position: absolute;
top: 0;
left: 0;
width: 298px;
height: 298px;
background: rgba(255,192,203,0.6);
border: 1px solid #ffffff;
float: left;
font: 100px/298px '黑体';
color: #fff;
text-align: center;
}
.box:nth-child(1){
transform: translateZ(150px);
}
.box:nth-child(2){
transform: rotateY(90deg) translateZ(150px);
}
.box:nth-child(3){
transform: rotateY(-90deg) translateZ(150px);
}
.box:nth-child(4){
transform: rotateX(90deg) translateZ(150px);
}
.box:nth-child(5){
transform: rotateX(-90deg) translateZ(150px);
}
.box:nth-child(6){
transform: translateZ(-150px);
}
</style>
</head>
<body>
<div class="main">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
</div>

</body>
</html>

猜你喜欢

转载自blog.51cto.com/13765978/2470942