コピペOK!

Webコーディング帳

光がパッと広がる

Button

HTML

            
<div class="btn anime-hirogaru">
  <span>Button</span>
</div>                
        

CSS

            
.anime-hirogaru {
  position: relative;
  overflow: hidden;
  z-index: 1;
  transition: transform 0.3s ease;
}

.anime-hirogaru:hover {
  transform: scale(1.05);
}

.anime-hirogaru::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: #FFD700;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.anime-hirogaru:hover::before {
  animation: pop-particles 0.6s ease forwards;
}

@keyframes pop-particles {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(12);
    opacity: 0;
  }
}

// ボタンのスタイル
.btn {
  background-color: #eb6100;
  width: 240px;
  height: 54px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin: 0 auto;
  box-shadow: 0px 4px 4px rgba($color: #000000, $alpha: .16);
  cursor: pointer;
  color: #fff;
}