老师,这样对吗?

来源:2-14 编程练习

张艺兴的宝贝

2022-08-14 15:02:39

<html lang="en">
<head>
<meta charset="UTF-8">
<title>空间移动</title>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    .box {
        width: 200px;
        height: 200px;
        margin: 200px auto;
        perspective: 300px;
        position: relative;
    }

    .box p {
        position: absolute;
        left: 0;
        top: 0;
        width: 200px;
        height: 200px;
    }

    /* 补充代码 */
    .box p:nth-child(1){
        background-color:greenyellow;
        transform:rotateX(90deg) translateZ(-50px);
    }
    .box p:nth-child(2){
        background-color:pink;
        transform:rotateX(257deg) translateZ(-70px);
        top: 50px;
    }
    .box p:nth-child(3){
        background-color:blue;
        transform:rotateX(284deg) translateZ(102px);
        top: 20px;
    }
</style>
</head>
<body>
<div class="box">
    <p></p>
    <p></p>
    <p></p>
</div>
</body>
</html>


写回答

1回答

imooc_慕慕

2022-08-14

同学你好,代码思路是对的,有一个小细节需要注意一下,第一个p标签与与其位置不对应,参考如下:

https://img.mukewang.com/climg/62f8a14c09d21bd814080286.jpg



修改参考:

https://img.mukewang.com/climg/62f8a1d3091f3ec604930234.jpg


https://img.mukewang.com/climg/62f8a1af09bb47ea13720257.jpg

关于角度问题,同学可以通过控制台自行调节一下即可。

祝学习愉快~

1

0 学习 · 17877 问题

查看课程