css3 3d立方体练习

<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.box{
width: 200px;
height: 200px;
position: relative;
margin: 100px auto;
transform-style: preserve-3d;
transform:rotateX(45deg) rotateY(45deg);
font-size: 50px;
color: white;
text-align: center;
line-height: 200px;
}
.box div{
width: 200px;
height: 200px;
position: absolute;
background-color: red;
/*opacity设置元素的透明度 默认是1*/
opacity: .3;
}
.box>div:first-child{
transform: translateZ(100px);
background-color: black;
}
.box>div:nth-child(2){
background-color: yellow;
transform: rotateY(-90deg) translateZ(100px);
}
.box>div:nth-child(3){
background-color: purple;
transform: rotateX(90deg) translateZ(100px);
}
.box>div:nth-child(4){
background-color: black;
transform: rotateX(-90deg) translateZ(100px);
}
.box>div:nth-child(5){
background-color: greenyellow;
transform: rotateY(-90deg) translateZ(-100px);
}
.box>div:last-child{
transform: translateZ(-100px);
}
</style>
</head>
<body>
<div class="box">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</body>
</html>

posted @ 2017-02-11 11:48  AdiaLike  阅读(187)  评论(0编辑  收藏  举报