<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>立方体</title>
<style>
.box{
width: 200px;
height: 200px;
position: relative;
top: 65px;
margin: 50px;
transform-style:preserve-3d ;/*给子级设置3d效果*/
transform: rotateX(33deg) rotateY(39deg) rotateZ(0deg) translate3d(0px,0px,0px);
}
.back1{
width: 100px;
height: 100px;
position: absolute;
background-color: chartreuse;
opacity: 0.5;/*设置透明效果*/
transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate3d(0px,0px,100px);
}
.back2{
width: 100px;
height: 100px;
position: absolute;
background-color: #ff2d27;
opacity: 0.5;
transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate3d(0px,0px,0px);
}
.back3{
width: 100px;
height: 100px;
position: absolute;
background-color: #e492ff;
opacity: 0.5;
transform: rotateX(0deg) rotateY(90deg) rotateZ(0deg) translate3d(-50px,0px,50px);
}
.back4{
width: 100px;
height: 100px;
position: absolute;
background-color: #2f18a1;
opacity: 0.5;
transform: rotateX(0deg) rotateY(90deg) rotateZ(0deg) translate3d(-50px,0px,-50px);
}
.back5{
width: 100px;
height: 100px;
position: absolute;
background-color: #12fffd;
opacity: 0.5;
transform: rotateX(90deg) rotateY(0deg) rotateZ(0deg) translate3d(0px,50px,-50px);
}
.back6{
width: 100px;
height: 100px;
position: absolute;
background-color: #421221;
opacity: 0.5;
transform: rotateX(90deg) rotateY(0deg) rotateZ(0deg) translate3d(0px,50px,50px);
}
</style>
</head>
<body>
<div class="box">
<div class="back1"></div>
<div class="back2"></div>
<div class="back3"></div>
<div class="back4"></div>
<div class="back5"></div>
<div class="back6"></div>
</div>
</body>
</html>
用css做立方体
最新推荐文章于 2023-03-13 22:43:54 发布