AD

 CSS 누르고 있으면 파티클이 날아다니는 버튼 예제

Broadcaster Million_Air
2023-07-12 15:42:21 70 0 1

<주의>

본문 내용은 추천, 비추천 버튼을 예시로 제작 되었습니다.
다른 버튼이나 모든 버튼에 적용시킬 경우 조금의 수정이 필요합니다.




/* 색 설정 */
html { --btcolor: #888; }
html.darkmode { --btcolor: #AAA; }

/* display 설정 */
#article-content-wrapper>.vote-area {
    display: flex;
    align-items: center;
    justify-content: center;
}
/* 버튼 설정 */
#article-content-wrapper>.vote-area>button { margin: 0 3px; position: relative; }
#article-content-wrapper>.vote-area>button:active { transform: scale(0.92); }
#article-content-wrapper>.vote-area>button:before,
#article-content-wrapper>.vote-area>button:after {
    content: "";
    display: block;
    left: -30%;
    position: absolute;
    width: 160%;
    height: 80%;
    background-repeat: no-repeat;
    pointer-events: none;
}

#article-content-wrapper>.vote-area>button:active::before {
  top: -60%;
  background-image: radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, transparent 20%, var(--btcolor) 20%, transparent 30%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, transparent 10%, var(--btcolor) 15%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%);
  background-size: 20% 20%, 30% 30%, 22% 22%, 28% 28%, 32% 32%, 20% 20%, 18% 18%, 15% 15%, 24% 24%;
  animation: topBubbles ease-in-out 0.6s forwards infinite;
}

@keyframes topBubbles {
  0% { background-position: 5% 90%, 10% 90%, 10% 90%, 15% 90%, 25% 90%, 25% 90%, 40% 90%, 55% 90%, 70% 90%; }
  50% { background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%; }
  100% { background-position: 0% 70%, 0% 10%, 10% 30%, 20% -10%, 30% 20%, 22% 40%, 50% 40%, 65% 10%, 90% 20%;
  background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}

#article-content-wrapper>.vote-area>button:active::after {
  bottom: -60%;
  background-image: radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, transparent 10%, var(--btcolor) 15%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%),
    radial-gradient(circle, var(--btcolor) 20%, transparent 20%);
  background-size: 22% 22%, 30% 30%, 32% 32%, 36% 36%, 22% 22%, 24% 24%, 30% 30%;
  animation: bottomBubbles ease-in-out 0.6s forwards infinite;
}

@keyframes bottomBubbles {
  0% { background-position: 10% -10%, 30% 10%, 55% -10%, 70% -10%, 85% -10%, 70% -10%, 70% 0%; }
  50% { background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%; }
  100% { background-position: 0% 90%, 20% 90%, 45% 70%, 60% 110%, 75% 80%, 95% 70%, 110% 10%;
    background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
}


출처 : https://www.codingnepalweb.com/button-click-animation-html-css-javascript/

radial-gradient: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/radial-gradient

후원댓글 1
댓글 1개  
이전 댓글 더 보기
TWIP 잔액: 확인중
▼아랫글 의사클래스 :is Million_Air
 공지 메모장 자료실 CSS 정보 추천 건의함 Q&A
0
 CSS
CSS 선택자
Broadcaster Million_Air
10-12
0
 자료실
트게더 CSS 테스트 [3]
Broadcaster Million_Air
09-07
0
 정보
FontAwesome Icon 사용하기
Broadcaster Million_Air
08-28
1
 CSS
의사클래스 :is
Broadcaster Million_Air
05-15
0
02-27
1
 자료실
배경용 패턴 디자인
Broadcaster Million_Air
01-21
0
01-11
0
01-11
2
 정보
나이트봇 200% 활용하기 [1]
Broadcaster Million_Air
06-23
2
 자료실
트게더 Fontawesome 리스트 [1]
Broadcaster Million_Air
12-09
인기글 글 쓰기