老师帮忙看一下我中间那个绿色那块显示不出来?

来源:2-14 编程练习

慕仰1291499

2022-05-06 20:30:00

<!Doctype html>

<html>

<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:red;

        transform: rotateX(90deg) translateZ(50px);

    }

     .box p:nth-child(2){

        background-color:green;

        transform: rotateX(90deg);

    }

     .box p:nth-child(3){

        background-color:blue;

        transform: rotateX(-90deg) translateZ(50px)

    }

</style>

</head>

<body>

<div class="box">

    <p></p>

    <p></p>

    <p></p>

</div>

</body>

</html>

下载视频          
写回答

1回答

好帮手慕久久

2022-05-07

同学你好,设置了perspective属性后,3d旋转会有立体效果,此时translate和rotate这些属性之间的效果会相互影响。绿色的p标签由于没有设置translateZ,导致它此时的位置刚好垂直页面所以就看不到了,调整旋转角度就行了:

https://img.mukewang.com/climg/6275cee4092dc65905550145.jpg

为了与练习中的效果一致,建议微调一下第一个p的旋转角度:

https://img.mukewang.com/climg/6275cf3b0985857706850195.jpg

祝学习愉快!

0

0 学习 · 15276 问题

查看课程