position : 문서 상에 요소를 배치하는 방법을 지정하는 속성
- relative : 요소 자기 자신을 기준으로 배치
- absolute : 부모 (조상) 요소를 기준으로 배치 (자식)
- fixed : viewport 기준으로 배치 (고정)
> 조상 요소 위치 기준으로 (top, bottom, left, right) 에서 얼만큼 떨어질 지 결정
.parent {
position: relative;
width: 300px;
height: 300px;
border: 3px dotted black;
}
.first {
position: absolute;
width: 100px;
height: 100px;
background-color: crimson;
}
.second {
position: absolute;
width: 50px;
height: 50px;
background-color: darkgoldenrod;
}
.third {
position: absolute;
width: 30px;
height: 30px;
background-color: pink;
}

> parent 요소에 position: relative; 값을 부여하고, 각 다른 세가지 색상의 블록에 position: absolute; 값을 모두 부여 했을 때
.parent {
position: relative;
width: 300px;
height: 300px;
border: 3px dotted black;
}
.first {
width: 100px;
height: 100px;
background-color: crimson;
}
.second {
position: relative;
width: 100px;
height: 100px;
right: 50px;
background-color: darkgoldenrod;
}
.third {
width: 100px;
height: 100px;
background-color: pink;
}

1번, 3번 블록은 부모 요소를 기준으로 배치되고, position: relative; 의 값을 갖는 2번 블록만 문서 상 본인의 원래 위치에 배치됨
.third {
position: fixed;
width: 100px;
height: 100px;
right: 50px;
bottom: 50px;
background-color: pink;
}

3번 블록에 position: fixed; 값을 주었을 때, 뷰포트를 기준으로 fix 됨