position: relative;
top: 40px;
left: 40px;
position: absolute;
top: 40px; left: 40px;
즉 조상을 따라 올라가다가 요소중에 position이 static이 아닌 요소가 있다면 그 요소가 배치 기준이 되는 것이다. static이 아닌 요소가 없다면 최상위의 body가 기준이 되겠다.
하지만 이러면 복잡하니까.. 어떤 요소의 position 속성을 absolute로 설정하면, 부모 요소의 position 속성을 relative로 지정해주는 것이 관례이다.
position: absolute;
bottom: 40px;
right: 40px;
position: fixed;
top: 40px; left: 40px;
position: sticky;
top: 20px;
<style>
.box1{
width: 200px;
height: 100px;
position: absolute;
z-index: 1;
}
.box2{
width: 200px;
height: 100px;
position: absolute;
z-index: 2;
}
</style>
z-index가 높을수록 더 위에 있는 것이다.
/* 키워드 값 */
float: left;
float: right;
float: none;
float: inline-start;
float: inline-end;

.parent {
overflow: hidden; /* float된 자식 요소를 감쌈 */
}
left : 왼쪽으로 붙는 float 정렬을 취소 한다.
right: 오른쪽으로 붙는 float 정렬을 취소 한다.
both : 왼쪽, 오른쪽 모두 붙는 float 정렬을 취소한다.
div#a {
float: right;
}
p#text {
clear: right;
}
div#a {
float: left;
}
div#b {
float: right;
}
p#text {
clear: both;
}
.parent::after {
content: '';
display: block;
clear: both;
}
출처
https://developer.mozilla.org/ko/docs/Web/CSS/position
https://developer.mozilla.org/ko/docs/Web/CSS/float
https://ddorang-d.tistory.com/12