💡 Position
- 움직이는 방법
- 위치 속성과 함께 사용
🖍 position은 방법을 설명하는 것
🖍 움직이게 하는 것은 top/left/right/bottom이 하는 것
top/left/right/bottomstatic인 경우 제외)absolute, fixed, sticky인 경우만 사용 가능margin : auto 사용 가능margin : auto 사용 ❌📌
float과 마찬가지로 뜨는성격을 가지고 있음
float/position:absolute/position:fixed는 같은 성질 가지고 있음
📌 가운데 정렬은 할 수 있음 (margin : auto가 안되는거)
z-index 속성 사용 (z-index 속성 있는게 앞, 없는게 뒤)z-index는 꼭 position 속성이랑 같이 써야함
margin : auto 사용 가능
position:relative -> left:100px은 부모 기준인 orange부터 100px 떨어진 것position:absolute -> pink를 감싸는 부모나 조상이 position이 없으면 body기준으로 100px임, 만약 blue가 position이 있으면 blue부터 100px임, 나를 감싸는 상위 요소 중 포지션이 있는 가장 가까운 곳에서 기준📌 기준 정의
1. 움직이는 대상의 position이 relative인 경우
- 부모요소가 기준
2. 움직이는 대상의 position이 absolute인 경우
- position 속성은 position 속성을 가지는 상위 요소가 기준
- 상위 요소 중 position 속성을 가지는 요소가 없는 경우
document가 기준
fixed는 스크린 기준 parallax scrollingmargin : auto 사용 ❌