Back to CSS Button Hover Effects Center Underline Draw Pure CSS
Share
HTML
<button class="bhe-08__btn">Hover Me</button>
CSS
.bhe-08__btn {
  padding: 12px 32px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  color: inherit;
  background: transparent;
}

.bhe-08__btn {
  position: relative;
  background: transparent;
  border: none;
}
.bhe-08__btn::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  right: 50%;
  height: 2px;
  background: linear-gradient(90deg, #7c6cff, #ff6c8a);
  transition:
    left 0.4s cubic-bezier(0.23, 1, 0.32, 1),
    right 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  border-radius: 2px;
}
.bhe-08__btn:hover::after {
  left: 32px;
  right: 32px;
}