پیش‌نمایش زنده
کد HTML
<div class="button-container">
  <div class="hover-left"></div>
  <div class="hover-right"></div>
  <button class="button">
    <span class="button-text">BUTTON</span>
  </button>
</div>
کد CSS
.button-container {
  position: relative;
  width: 260px;
  height: 90px;
}

.button {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #e8e8e8, #c8c8c8);
  border: 3px solid #a0a0a0;
  border-radius: 45px;
  padding: 15px;
  box-sizing: border-box;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.15),
    inset 0 2px 4px rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  user-select: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner button surface */
.button::after {
  content: "";
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  background: linear-gradient(145deg, #f2f2f2, #d8d8d8);
  border-radius: 45px;
  box-shadow:
    inset 0 1px 3px rgba(255, 255, 255, 0.8),
    inset 0 -1px 3px rgba(0, 0, 0, 0.15),
    0 1px 2px rgba(255, 255, 255, 0.5);
}

.button-text {
  font-size: 16px;
  font-weight: 600;
  color: #555;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  pointer-events: none;
  position: relative;
  z-index: 10;
}

/* Invisible hover zones */
.hover-left,
.hover-right {
  position: absolute;
  top: 0;
  width: 40%;
  height: 100%;
  z-index: 15;
}

.hover-left {
  left: 0;
}

.hover-right {
  right: 0;
}

/* Default hover effect (center area) */
.button:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

/* Left side tilt */
.hover-left:hover ~ .button {
  transform: translateY(-2px) rotate(-3deg);
  transform-origin: center bottom;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

/* Right side tilt */
.hover-right:hover ~ .button {
  transform: translateY(-2px) rotate(3deg);
  transform-origin: center bottom;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(255, 255, 255, 0.5),
    inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

/* Active/pressed state */
.button:active,
.hover-left:active ~ .button,
.hover-right:active ~ .button {
  transform: scale(0.95) translateY(1px) !important;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.2),
    inset 0 4px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
  background: linear-gradient(145deg, #d0d0d0, #e0e0e0);
}

.button:active::after,
.hover-left:active ~ .button::after,
.hover-right:active ~ .button::after {
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.3),
    inset 0 -1px 2px rgba(255, 255, 255, 0.2);
}

.button:active .button-text,
.hover-left:active ~ .button .button-text,
.hover-right:active ~ .button .button-text {
  transform: translateY(1px);
}

/* Subtle shine effect */
.button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
  border-radius: 30px;
}

.button:hover::before,
.hover-left:hover ~ .button::before,
.hover-right:hover ~ .button::before {
  left: 100%;
}
نوع: button
تاریخ ایجاد: 2026/06/05
آخرین بروزرسانی: 2026/06/05