其他分享
首页 > 其他分享> > 立体呈现-第二十五天

立体呈现-第二十五天

作者:互联网

立体呈现

目标:使用tranform-style:preserve-3d呈现立体图形

实现正方体

<!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>
        .box{
            width: 200px;
            height: 200px;
            position: relative;
            margin: 200px auto;
            /* 添加透视 */
            perspective: 1000px;
            /* 保留子元素的三维变化效果 */
            transform-style: preserve-3d;
            transform: rotate3d(1,1,0,-30deg);

        }
        .face{
            width: 200px;
            height: 200px;
            position: absolute;
            left: 0;
            top: 0;
            background-color: rgba(255, 0, 0, 0.4);
        }
        .face:nth-of-type(1){
            transform: translateZ(100px);
        }
        .face:nth-of-type(2){
            transform: translateZ(-100px) rotateY(180deg);
        }  
        .face:nth-of-type(3){
            transform: translateX(-100px) rotateY(-90deg);
        }  
        .face:nth-of-type(4){
            transform: translateX(100px) rotateY(90deg);
        }  
        .face:nth-of-type(5){
            transform: translateY(-100px) rotateX(90deg);
        }  
        .face:nth-of-type(6){
            transform: translateY(100px) rotateX(-90deg);
        }  
    </style>
</head>
<body>
    <div class="box">
        <div class="face" style="background: green;">1</div>
        <div class="face" style="background: pink;">2</div>
        <div class="face" style="background: blue;">3</div>
        <div class="face" style="background: yellow;">4</div>
        <div class="face" style="background: white;">5</div>
        <div class="face" style="background: black;">6</div>
    </div>
</body>
</html>

标签:呈现,100px,transform,face,立体,nth,第二十五,type,200px
来源: https://www.cnblogs.com/cm666/p/16227227.html