Front-End/CSS
[CSS] Ex16_absolute.html
이뮨01
2023. 6. 12. 13:31
position 속성 값인 relative와 absolute의 개념을 더 자세히 배우다.
<!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>
#parent{
width: 500px;
height: 600px;
background-color: gray;
position: relative;
}
.box{
width: 200px;
height: 200px;
/* border: 1px solid; */
}
.child1{
background-color: #ff4949;
position: absolute;
bottom: 0;
right: 0;
}
.child2{
background-color: #f9ca24;
}
.child3{
background-color: #0984e3;
position: relative;
bottom: 0px;
right: 20px;
}
</style>
</head>
<body>
<div id="parent">
<div class="box child1"></div>
<div class="box child2"></div>
<div class="box child3"></div>
</div>
</body>
</html>
parent 아이디를 가진 회색 영역 안의 child1 빨간 영역이 absolute라서 회색 우측하단에 위치하게 된다.