CSS로 웹사이트를 아름답게 만드는 방법을 연구중이다🧐
그 중 underline에 애니메이션을 넣어보는 것을 공부해보기로 했다🤍
💬 이런 분들에게 추천드려요 👧👦
✅ CSS를 애정하는 사람
✅ 밑줄에 애니메이션 넣어보고 싶은 사람
✅ CSS로 애니메이션 공부하고 싶은 사람
예시를 바로 보고 싶다면 하단 [Codepen Example]을 통해 볼 수 있다! 오른쪽 목차를 이용하자 😋
.underline1 {
cursor: pointer;
color: #7DD4E7;
/*2개 그라디언트 underline 만드는 방법*/
background-image:
linear-gradient(rgb(176, 251, 188), rgb(176, 251, 188)),
linear-gradient(#E5FAFF, #7DD4E7);
background-size: 100% 2px, 100% 2px;
background-position: 100% 100%, 0 100%;
background-repeat: no-repeat, no-repeat;
transition: background-size 700ms linear;
}
.underline1:hover {
background-size: 0 2px, 100% 2px;
}
.underline2 {
cursor: pointer;
color: #fc00ff;
/*3개 그라디언트 underline 만드는 방법*/
background-image:
linear-gradient(#FFF, #F0F0EB),
linear-gradient(#fc00ff, #00dbde),
linear-gradient(#A1FFCE, #FAFFD1);
background-size: 20px 2px, 100% 2px, 0 2px;
background-position: calc(20px * -1) 100%, 100% 100%, 0 100%;
background-repeat: no-repeat;
transition: background-size 2s linear, background-position 2s linear;
}
.underline2:hover {
background-size: 20px 2px, 0 2px, 100% 2px;
background-position: calc(100% + 20px) 100%, 100% 100%, 0 100%;
}
.underline3 {
text-decoration: underline 2px #004FF9;
transition: text-decoration-color 300ms;
}
.underline3:hover {
text-decoration-color: #FFF94C;
}
.underline4 {
text-decoration: underline 2px #FFF94C;
text-underline-offset: 0;
transition: text-decoration-color 300ms, text-underline-offset 800ms;
}
.underline4:hover {
text-decoration-color: orange;
text-underline-offset: 4px;
}
참고 웹사이트: https://nickymeuleman.netlify.app/blog/css-animated-wrapping-underline