Back to CSS Button Hover Effects Glitch Slice Pure CSS
Share
HTML
<button class="bhe-03__btn" data-text="GLITCH">GLITCH</button>
CSS
.bhe-03__btn {
  padding: 12px 32px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.02em;
  background: transparent;
  color: inherit;
}

.bhe-03__btn {
  position: relative;
  overflow: hidden;
}
.bhe-03__btn::before,
.bhe-03__btn::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}
.bhe-03__btn::before {
  background: #ff6c8a;
  color: #fff;
  clip-path: polygon(0 30%, 100% 30%, 100% 50%, 0 50%);
}
.bhe-03__btn::after {
  background: #7c6cff;
  color: #fff;
  clip-path: polygon(0 55%, 100% 55%, 100% 75%, 0 75%);
}
.bhe-03__btn:hover::before {
  animation: glitch1 0.3s steps(1) infinite;
}
.bhe-03__btn:hover::after {
  animation: glitch2 0.3s steps(1) infinite 0.05s;
}
@keyframes glitch1 {
  50% {
    opacity: 1;
    transform: translateX(-4px);
  }
}
@keyframes glitch2 {
  50% {
    opacity: 1;
    transform: translateX(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bhe-03__btn,
  .bhe-03__btn * {
    animation: none !important;
  }
}