본문 바로가기
Front-end/애니메이션

사용자 클릭 시 애니메이션을 구현하는 방법

by mooyou 2025. 3. 18.
728x90
300x250
SMALL

 

사용자 클릭 시 애니메이션을 구현하는 방법

예를 들어, 버튼을 클릭하면 버튼이 부풀어오르는 애니메이션을 적용하거나, 클릭을 통해 다른 콘텐츠가 나타는 효과를 만들 수 있다.

 

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="UTF-8">
  <title>클릭 애니메이션</title>
  <style>
    .btn {
      display: inline-block;
      padding: 15px 30px;
      background-color: #3498db;
      color: white;
      font-size: 18px;
      border: none;
      cursor: pointer;
      border-radius: 8px;
      transition: transform 0.3s ease;
    }
    .btn:active {
      transform: scale(1.1);
    }
  </style>
</head>
<body>
  <button class="btn">클릭하세요</button>
</body>
</html>

 

  • 위 코드는 사용자가 버튼을 클릭했을때 transform:scale(1.1)효과로 버튼이 부풀어 오르는 애니메이션을 구현한다.
  • transition: transfrom 0.3s ease로 애니메이션의 속도와 스타일을 설정하여 부드러운 효과를 만들 수 있다.

 

728x90
반응형
LIST

댓글