CSS입문

CSS_position(absolute)_22.04.12(Tue)

양빵빵 2022. 4. 12. 15:32

<!DOCTYPE html>
<html lang="ko">

<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>
        .container {
            margin: 100px;
        }

        .box {
            width: 100px;
            height: 100px;
            background: orange;
            border: 4px dashed red;
            text-align: center;
            line-height: 100px;
            /* 텍스트 y축 중앙정렬 */

        }

        .box:nth-child(2) {
            position: absolute;
            left: 60px;
            top: 60px;
         
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
    </div>
</body>

</html>