Step it up now

[CSS] Position- relative /absolute 3 본문

수업/JavaScript, css, html

[CSS] Position- relative /absolute 3

케잉 2023. 11. 1. 17:43

▶html

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel = "stylesheet" href="a3.css">
</head>
<body>
    <div class="parent">
        <div class="child">123</div>
        <div class="child abs">456</div>
    </div>    
</body>
</html>

 

▶ css 

.parent{
    border: 5px solid blue;
    color: blue;
    background-color: lavender;
    padding: 1rem;
    position: relative; /*상위클래스(나)를 기준으로 벗어나지 않도록*/ 
}

.child{
    border: 2px dotted red;
    color: black;
    background-color: hotpink;
    padding: 1rem;
}

.abs {
    position: absolute;
    top:0px;
    left: 0px;
}

 

'수업 > JavaScript, css, html' 카테고리의 다른 글

원시형 / boolean  (0) 2023.11.12
Firebase  (0) 2023.11.08
[CSS] Position- relative /absolute 2  (0) 2023.10.31
[CSS] Position- relative /absolute  (0) 2023.10.31
html 1  (0) 2023.10.30