본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Affix

원문 보기 위키 갱신

스크롤해도 콘텐츠가 지정한 위치에 붙어 있게 해 주는 컴포넌트예요. position: sticky와 비슷하지만 트리거 지점이나 위치 속성을 더 세밀하게 제어할 수 있어요. 툴바나 목차 고정에 많이 쓰여요.

출처: 문서

본문

Affix는 스크롤할 때 콘텐츠를 고정된 자리에 붙어 있게 해 줘요. position: sticky와 비슷하지만 더 많은 일을 할 수 있어요.

Demos

basic.vue
position.vue

API

Affix Props

이름 타입 기본값 설명
bottom number undefined 아래쪽 affix가 트리거된 뒤의 css bottom 속성. (설정하지 않으면 trigger-bottom 속성을 사용해요)
listen-to string | HTMLElement | Document | Window | (() => HTMLElement) document 스크롤을 감청할 스크롤 요소.
trigger-bottom number undefined 타깃 하단에서 아래쪽 affix를 트리거할 거리(px). (설정하지 않으면 bottom 속성을 사용해요)
trigger-top number undefined 타깃 상단에서 위쪽 affix를 트리거할 거리(px). (설정하지 않으면 top 속성을 사용해요)
position 'fixed' | 'absolute' 'fixed' affix의 CSS position.
top number undefined 위쪽 affix가 트리거된 뒤의 css top 속성. (설정하지 않으면 trigger-top 속성을 사용해요)

더 알아보기 (Learn more)

위쪽 고정과 아래쪽 고정의 차이는 position 데모에서 확인할 수 있어요. 목차 고정이 목적이라면 Anchor 컴포넌트 문서도 참고하세요.