使用旋转制作正方体

使用旋转制作正方体

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MTB</title>
<style>
* {
padding: 0;
margin: 0;
}
.box {
width: 200px;
height: 200px;
margin: 100px auto;
perspective: 300px;
position: relative;
}
.box p {
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
}
.box p:nth-child(1) {
background-color: rgba(243, 195, 118, 0.356);
/* 前面 */
transform: translateZ(100px);
}
.box p:nth-child(2) {
background-color: rgba(214, 247, 70, 0.356);
/* 顶部 */
transform: rotateX(90deg) translateZ(100px);
}
.box p:nth-child(3) {
background-color: rgba(163, 248, 93, 0.479);
/* 背面 */
transform: rotateX(180deg) translateZ(100px);
}
.box p:nth-child(4) {
background-color: rgba(118, 243, 237, 0.356);
/* 下面 */
transform:rotateX(90deg) translateZ(-100px);
}
.box p:nth-child(5) {
background-color: rgba(118, 156, 243, 0.356);
/* 左面 */
transform:rotateY(90deg) translateZ(-100px);
}
.box p:nth-child(6) {
background-color: rgba(197, 118, 243, 0.356);
/* 右面 */
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

登陆购买课程后可参与讨论,去登陆

1回答
樱桃小胖子 2021-10-08 13:35:09

同学你好,这个代码和效果是正确的,同学是有什么疑惑么?如果有,请详细描述你的疑惑。便于准确定位问题并帮助解答。

祝学习愉快!

  • 提问者 日拱一卒_ #1

    谢谢老师,暂时没有疑问,发到这里想记录一下,便于后续学习查看

    2021-10-08 14:05:00
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师