老师正方体这样写对吗

来源:2-12 空间移动

咸鱼王派大星

2021-03-09 11:12:16

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box{
width: 200px;
height: 200px;
border: 1px solid #000;
margin: 100px auto;
perspective:300px;
position: relative;
}
.box p{
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
}
.box p:first-child{
background-color: rgba(219,56,211,0.486);
/* 正前那个面 */
transform: translateZ(100px);
}
.box p:nth-child(2){
background-color: rgba(91, 241, 22, 0.486);
/* 顶面那个面 */
transform: rotateX(90deg) translateZ(100px);
}
.box p:nth-child(3){
background-color: rgba(8, 73, 250, 0.486);
/* 背面那个面 */
transform: translateZ(-100px);
}
.box p:nth-child(4){
background-color: rgba(13, 243, 212, 0.486);
/* 底面那个面 */
transform: rotate(90deg) translateZ(-100px);
}
.box p:nth-child(5){
background-color: rgba(240, 217, 9, 0.486);
/* 左边那个面 */
transform: rotateY(90deg) translateZ(100px);
}
.box p:nth-child(6){
background-color: rgba(247, 127, 16, 0.486);
/* 右边那个面 */
transform: rotateY(90deg) translateZ(-100px);
}
</style>
</head>

<body>
<div class="box">
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
</body>

</html>


写回答

1回答

好帮手慕夭夭

2021-03-09

同学你好,这样可以的。但是不知道为啥要加一个边框,建议把边框去掉,这样不会影响视觉效果哦。如下:

http://img.mukewang.com/climg/6046ebe8097fd58104640132.jpg

祝学习愉快~

0

0 学习 · 15276 问题

查看课程