(기초)그래서 뭘 배운거야?/HTML&CSS

HTML&CSS-107-transform-style : perspective요소 하위 상속

Soheny.P 2021. 8. 31. 21:59
728x90
<!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>
    <!-- 
        * transform-style : perspective 요소를 하위 요소로도 상속 또는 비상속 하기 위한 속성
                            하위 요소가 상위 perspective 영향 받을지, 받지 않을지를 결정한다.
                            float(영향 없음)이 default
                            영향이 받게 하려면 preserve-3d 속성 선택

     -->
    <style>
        div {
            width: 200px;
            height: 200px;
        }
        .container {
            border: 1px solid black;
            perspective: 300px;
            margin-top: 100px;
            margin-left: 100px;
            float: left;
        }
        .box1 {
            background-color: plum;
            transform: rotateY(45deg);
        }
        .box2 {
            background-color: salmon;
            transform: rotateX(45deg);
        }
        #tr-style1 {
            transform-style: flat;
        }
        #tr-style2 {
            transform-style: preserve-3d;
        }
    </style>
</head>

<body>
    <!-- div.container*2>div.box1#tr-style$>div.box2 -->
    <div class="container">
        <div class="box1" id="tr-style1">
            <div class="box2"></div>
        </div>
    </div>
    <div class="container">
        <div class="box1" id="tr-style2">
            <div class="box2"></div>
        </div>
    </div>
</body>

</html>
728x90