.container { position: relative; top: 20px; left: 50px; border: 5px solid green; width: 400px; height: 200px; } .content { position: relative; top: 20px; left: 50px; border: 5px solid red; width: 200px; height: 100px; }
상대적인 위치를 설정하지 않은 경우
:: static일 때와 같은 곳에 위치한다.
(상대적인 위치 설정 후) 조상 element의 Position이 모두 static인 경우
:: html이 기준(컨테이닝 블록)이 된다.
.container { border: 5px solid green; width: 400px; height: 200px; } .content { position: absolute; right: 0; border: 5px solid red; width: 200px; height: 100px; }
.container { position: relative; border: 5px solid green; width: 400px; height: 200px; } .content { position: absolute; right: 0; border: 5px solid red; width: 200px; height: 100px; }
** 뷰포트: 현재 창에서 문서를 볼 수 있는 부분, 전체화면이라면 화면 전체를 말한다.
.container { border: 5px solid green; width: 400px; height: 200px; } .content { position: fixed; top: 150px; left: 50px; border: 5px solid red; width: 200px; height: 100px; }