css3 按照3维空间摆放

WX20200719-125823@2x.png
<!doctype html>
<html>
    <head>
        <title>标题</title>
        <meta charset="utf-8">
        <style>
            #parent{
                width:400px;
                height:400px;
                border:1px solid #333;
                margin:0 auto;
                margin-top:100px;
                /*规定 子元素以什么样的方式进行显示*/
                -webkit-transform-style:preserve-3d;
                /**/
                /*-webkit-perspective:1000px;*/
                position:relative;
                transform:rotatex(-20deg);
            }
            #son{
                width:200px;
                height:200px;
                background:#f00;
                position:absolute;
                top:100px;
                left:100px;
                /*旋转 60 deg*//*改变 z 轴位置*/
                transform:rotatey(60deg) translatez(200px);
            }
            #daughter{
                width:200px;
                height:200px;
                background:#0f0;
                position:absolute;
                top:100px;
                left:100px;
                /*改变 z 轴位置*/
                transform:translatez(200px);
            }
            #yeye{
                /**/
                -webkit-perspective:1000px;
            }
        </style>
    </head>
    <body>
    <div id="yeye">
        <div id="parent">
            <div id="son">3D位移元素</div>
            <div id="daughter">3D位移元素</div>
        </div>
    </div>
    </body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容