پیشنمایش زنده
کد HTML
<button class="button">
<span>DANGER ZONE</span>
</button>
کد CSS
.button {
border: none;
position: relative;
width: 220px;
height: 70px;
padding: 0;
z-index: 2;
clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
cursor: pointer;
background: transparent;
transition: transform 0.2s ease;
}
.button:after {
content: "";
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: linear-gradient(45deg, #c0392b, #e74c3c);
clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
z-index: -1;
opacity: 0;
transition: opacity 0.3s ease;
}
.button:hover:after {
opacity: 1;
}
.button span {
position: absolute;
width: 100%;
font-size: 18px;
font-weight: 900;
left: 50%;
top: 50%;
letter-spacing: 1.5px;
text-align: center;
transform: translate(-50%, -50%);
color: #e74c3c;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
transition:
color 0.3s ease,
transform 0.3s ease;
}
.button:hover span {
color: #fff;
transform: translate(-50%, -50%) rotate(-2deg);
}
.button:before {
content: "";
position: absolute;
width: 0;
height: 100%;
background: rgba(0, 0, 0, 0.3);
left: 0;
top: 0;
z-index: 0;
transition: width 0.4s ease-out;
clip-path: polygon(20% 10%, 80% 10%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
}
.button:hover:before {
width: 100%;
}
.button:hover {
transform: translateY(2px);
}