728x90
반응형
이번에 새로 만들어진 animation효과이다! scoll내리면 나오는 효과 주고 싶어서 gsap랑 이것 저것 찾아보던 중
animation-timeline을 발견했다! 너무너무 간편하게 사용할 수 있다!
📌animation-timeline : scroll()
animation-timeline:scroll(root block);
() 안에는 기준이 되는 스크롤바를 적어주면 된다.
오른쪽
nearest -> 가장 가까운 부모
self -> 나 자신
root -> viewpoint
왼쪽
block - 세로
inline - 가로
📌animation-timeline : view()
animation-timeline:view(root block);
view()는 브라우저 전체 기준이 아닌 현재 보여지는 화면이 기준이 된다.
응용해서 만든 scroll 양을 알려주는 상단바
HTML
<div className="scroll_top"></div>
CSS
.scroll_top {
z-index: 999;
background-color: #ffa47d;
position: fixed;
transform-origin: 0 50%;
width: 100vw;
height: 0.5em;
animation: grow auto linear both;
animation-timeline: scroll(root block);
}
@-webkit-keyframes grow {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1)
}
}
@keyframes grow {
from {
transform: scaleX(0);
}
to {
transform: scaleX(1)
}
}
참고자료
728x90
반응형
'Frontend > CSS' 카테고리의 다른 글
TailwindCSS란? (0) | 2023.12.29 |
---|---|
css - animation (2) | 2023.12.02 |
css - background 색상 여러개 사용하기 (0) | 2023.11.19 |
css - input 태그 안에 이미지 넣기 (feat. input background 투명하게, palceholder 색깔 넣기 등등... ) (0) | 2023.07.30 |
css - filter (0) | 2023.05.01 |