
html
<section>
<div class="arrow"></div>
<div class="arrow hr"></div>
<div class="arrow infi"></div>
</section>
css
section {
position: fixed;
left: 50%;
top: 50%;
}
/* 대각선 위 움직임 화살표 */
.arrow {
overflow: hidden;
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 100px;
width: 50px;
height: 50px;
background-color: #ccc;
border-radius: 50%;
font-size: 30px;
cursor: pointer;
transition: 0.5s;
}
.arrow:hover {
background-color: yellow;
}
.arrow::before {
content: '\1F86D';
position: absolute;
left: -50%;
bottom: -50%;
transition: .5s;
}
.arrow::after {
content: '\1F86D';
position: absolute;
left: 11px;
bottom: 5px;
transition: .5s;
}
.arrow:hover::before {
left: 11px;
bottom: 5px;
}
.arrow:hover::after {
left: 45px;
bottom: 45px;
}
/* 왼 → 오른쪽 움직임 화살표 */
.arrow.hr::before {
content: '\1F816';
position: absolute;
left: -50%;
bottom: 5px;
}
.arrow.hr::after {
content: '\1F816';
left: 13px;
}
.arrow.hr:hover::before {
left: 14px;
bottom: 5px;
}
.arrow.hr:hover::after {
left: 50px;
bottom: 5px;
}
/* 무한반복 움직임 화살표 */
.arrow.infi::before {
display: none;
}
.arrow.infi::after {
content: '\1F816';
position: absolute;
left: 11px;
bottom: 5px;
transition: .5s;
}
.arrow.infi:hover:after{
animation: infi 1s linear infinite;
}
@keyframes infi {
0% { transform: translateX(-35px); }
100% { transform: translateX(35px); }
}
arrow를 before와 after로 두 개 만든 후,
hover 하기 전과 후, 좌표수치 부여
위와 동일하게 arrow를 before와 after로 두 개 만든 후,
hover 하기 전과 후, 좌표수치 부여
infi라는 keyframes으로 transform x 좌표값을
처음0% -35px에서
마지막100% 35px로 이동하게 설정한다.
위와 같이 설정한 infi keyframes 을
.arrow.infi 화살표에 부여한다.
(📕 animation-play-state 속성을 활용하여
자바스크립트로 짜고 싶다면 아래 사이트 참고)
animation 참고 사이트
https://webclub.tistory.com/621
화살표 유니코드 참고 사이트
https://unicode-table.com/en/sets/arrow-symbols/