老师我这样写可以吗?背面直接沿Z轴-100px

来源:2-12 空间移动

激情的樱木花道

2021-05-31 11:49:29

<!DOCTYPE html>

<html lang="en">


<!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>Document</title>

    <style>

        * {

            margin0;

            padding0;

        }

        .box{

            width200px;

            height200px;

            border1px solid #000;

            margin:100px auto;

            perspective300px;

            position:relative;

        }

        .box p{

            position:absolute;

            top:0;

            left:0;

            width200px;

            height200px;

        }

        .box p:nth-child(1){

            background-colorrgba(2161091140.45);

            /* 前面 */

            transformtranslateZ(100px);

        }

        .box p:nth-child(2){

            background-colorrgba(49119400.45);

            /* 顶部 */

            transformrotateX(90degtranslateZ(100px);

        }

        .box p:nth-child(3){

            background-colorrgba(147761500.45);

            /* 背面 */

            /* transform:rotateX(180deg) translateZ(100px); */

            transform:translateZ(-100px);

        }

        .box p:nth-child(4){

            background-colorrgba(35251330.45);

            /* 底面 */

            transformrotateX(90degtranslateZ(-100px);

        }

        .box p:nth-child(5){

            background-colorrgba(531231700.45);

            /* 左侧面 */

            transformrotateY(90degtranslateZ(-100px);

        }

        .box p:nth-child(6){

            background-colorrgba(135153330.45);

            /* 右侧面 */

            transformrotateY(90degtranslateZ(100px);

        }

    </style>

</head>

<body>

    <div class="box">

        <p></p>

        <p></p>

        <p></p>

        <p></p>

        <p></p>

        <p></p>

    </div>

</body>

</html>


写回答

1回答

好帮手慕言

2021-05-31

同学你好,背面设置transform: translateZ(-100px)也是可以实现效果的。祝学习愉快~


0

0 学习 · 15276 问题

查看课程