پیشنمایش زنده
کد HTML
<div class="button">
<div class="bg"></div>
<div class="border"></div>
<div class="content">
<div class="svgBox">
<svg
xmlns="https://www.w3.org/2000/svg"
version="1.1"
width="100"
height="4"
class="svgLine"
>
<line
class="line"
x1="0"
y1="2"
x2="100"
y2="2"
fill="none"
stroke-linecap="round"
stroke-width="2"
stroke-dasharray="60"
></line>
</svg>
<svg
xmlns="https://www.w3.org/2000/svg"
version="1.1"
width="100"
height="4"
class="svgLine"
>
<line
class="line"
x1="0"
y1="2"
x2="100"
y2="2"
fill="none"
stroke-linecap="round"
stroke-width="2"
stroke-dasharray="60"
></line>
</svg>
<svg
xmlns="https://www.w3.org/2000/svg"
version="1.1"
width="100"
height="4"
class="svgLine"
>
<line
class="line"
x1="0"
y1="2"
x2="100"
y2="2"
fill="none"
stroke-linecap="round"
stroke-width="2"
stroke-dasharray="60"
></line>
</svg>
</div>
<span class="text" data-text="GO">GO</span>
</div>
</div>
کد CSS
.button {
--card-w: 160px;
--card-h: 48px;
width: var(--card-w);
height: var(--card-h);
border: 2px solid #333;
border-radius: 8px;
display: grid;
position: relative;
overflow: hidden;
cursor: pointer;
background-color: #222;
transition: transform 0.1s ease-in-out;
user-select: none;
&:active {
transform: scale(0.95);
}
&:hover .border {
opacity: 1;
}
&:hover .bg {
animation-play-state: paused;
filter: grayscale(0);
&::before {
animation-play-state: running;
opacity: 0.6;
}
}
&:hover .text {
transform: skewX(-15deg);
}
&:hover .svgBox {
opacity: 1;
width: 50px;
}
}
.bg {
--size: calc(max(var(--card-w), var(--card-h)) * 1.25);
width: var(--size);
height: var(--size);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
filter: grayscale(1);
animation: rotateBg 14s linear infinite;
animation-play-state: running;
&::before {
content: "";
width: 100%;
height: 100%;
display: block;
background: repeating-conic-gradient(
from 0deg at 50% 50%,
rgba(246, 194, 92, 0.75) 0deg,
rgba(246, 194, 92, 0.75) 15deg,
transparent 15deg,
transparent 30deg
);
opacity: 0.2;
transition: opacity 0.3s ease-in-out;
animation: rotateBgBefore 4s linear infinite;
animation-play-state: paused;
}
}
@keyframes rotateBg {
to {
transform: translate(-50%, -50%) rotate(360deg);
}
}
@keyframes rotateBgBefore {
to {
transform: rotate(360deg);
}
}
.border {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border-radius: 8px;
box-shadow: inset 0 0 16px 0 rgba(194, 194, 194, 0.75);
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
.content {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
position: absolute;
top: 0;
left: 0;
.text {
display: block;
font-size: 24px;
font-weight: 900;
color: #fff;
position: relative;
transition: transform 0.3s ease-in-out;
}
.svgBox {
width: 0px;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: flex-end;
gap: 2px;
transition: all 0.3s ease-in-out;
opacity: 0;
.svgLine {
position: relative;
}
.line {
stroke: #fff;
animation: animLine 0.6s linear infinite;
}
.svgLine:nth-child(1) {
transform: translateX(4px);
}
.svgLine:nth-child(3) {
transform: translateX(-4px);
}
.svgLine:nth-child(1) .line {
animation-delay: 0.2s;
}
.svgLine:nth-child(2) .line {
animation-delay: 0.1s;
}
}
}
@keyframes animLine {
0% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: 120;
}
}