پیش‌نمایش زنده
کد HTML
<button class="button">
  Hover me
</button>
کد CSS
.button {
  border: 0;
  padding: 1rem;
  background-color: orange;
  color: white;
  position: relative;
}

.button:hover {
  background-color: orangered;
  cursor: pointer;
  transition: all 0.15s ease-in;
}

.button:hover::before {
  content: "";
  width: 100%;
  height: 100%;
  background-color: cadetblue;
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  animation: swingLeft 0.2s ease-in forwards;
}

.button:hover::after {
  content: "";
  width: 100%;
  height: 100%;
  background-color: purple;
  position: absolute;
  z-index: -1;
  bottom: 0;
  right: 0;
  animation: swingRight 0.2s ease-in forwards;
}

@keyframes swingLeft {
  0% {
    top: 0;
    left: 0;
  }

  100% {
    top: 5px;
    left: 5px;
  }
}

@keyframes swingRight {
  0% {
    bottom: 0;
    right: 0;
  }

  100% {
    bottom: 5px;
    right: 5px;
  }
}
نوع: button
تاریخ ایجاد: 2026/06/05
آخرین بروزرسانی: 2026/06/05