position 속성 - relative, absolute, fixed 기본개념 및 복습

박준영·2021년 5월 12일

position-relative

  • 태그의 위치를 변경 시키고 싶을때 이용하며 top, right, bottom, left에 값을 주며 이동시킬 수 있습니다. relative, absolute를 이용하면 relative를 부모로 합니다.

position-solution

  • 부모의 값을 기준으로 top, right, bottom, left를 움직입니다.

예를들면

 .colorbox1 {
 	position:relative;
 }
 
 .colorbox2 {
 	position:absolute;
    left: 40px;
 }

이러한 css를 예시로 들자면 colorbox1이 relative 가 지정되어 있고, colorbox2는 absolute가 지정되어 있으므로 colorbox1이 부모가 되며 기준이 되어 colorbox2는 colorbox1 기준 왼쪽으로 40px 움직입니다.

position-fixed

  • fixed는 부모가 필요없고, 다른거와 다르게 화면을 스크롤하면 내용이 움직이지 않고 고정되는 부분을 fixed라고 합니다.

0개의 댓글