پیشنمایش زنده
کد HTML
<button class="button">
<p class="button__text">
<span style="--index: 0;">B</span>
<span style="--index: 1;">O</span>
<span style="--index: 2;">O</span>
<span style="--index: 3;">K</span>
<span style="--index: 4;"></span>
<span style="--index: 5;">N</span>
<span style="--index: 6;">O</span>
<span style="--index: 7;">W</span>
<span style="--index: 8;"></span>
<span style="--index: 9;">B</span>
<span style="--index: 10;">O</span>
<span style="--index: 11;">O</span>
<span style="--index: 12;">K</span>
<span style="--index: 13;"></span>
<span style="--index: 14;">N</span>
<span style="--index: 15;">O</span>
<span style="--index: 16;">W</span>
<span style="--index: 17;"></span>
</p>
<div class="button__circle">
<svg
width="14"
class="button__icon"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 14 15"
>
<path
fill="currentColor"
d="M13.376 11.552l-.264-10.44-10.44-.24.024 2.28 6.96-.048L.2 12.56l1.488 1.488 9.432-9.432-.048 6.912 2.304.024z"
></path>
</svg>
<svg
class="button__icon button__icon--copy"
xmlns="http://www.w3.org/2000/svg"
width="14"
fill="none"
viewBox="0 0 14 15"
>
<path
fill="currentColor"
d="M13.376 11.552l-.264-10.44-10.44-.24.024 2.28 6.96-.048L.2 12.56l1.488 1.488 9.432-9.432-.048 6.912 2.304.024z"
></path>
</svg>
</div>
</button>
کد CSS
.button {
cursor: pointer;
border: none;
background: #fef6f7;
color: #db5275;
width: 100px;
height: 100px;
border-radius: 50%;
overflow: hidden;
position: relative;
display: grid;
place-content: center;
transition:
background 300ms,
transform 200ms;
font-weight: 600;
}
.button__text {
position: absolute;
inset: 0;
animation: text-rotation 8s linear infinite;
> span {
position: absolute;
transform: rotate(calc(19deg * var(--index)));
inset: 7px;
}
}
.button__circle {
position: relative;
width: 40px;
height: 40px;
overflow: hidden;
background: #fff;
color: #db5275;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.button__icon--copy {
position: absolute;
transform: translate(-150%, 150%);
}
.button:hover {
background: #000;
transform: scale(1.05);
}
.button:hover .button__icon {
color: #000;
}
.button:hover .button__icon:first-child {
transition: transform 0.3s ease-in-out;
transform: translate(150%, -150%);
}
.button:hover .button__icon--copy {
transition: transform 0.3s ease-in-out 0.1s;
transform: translate(0);
}
@keyframes text-rotation {
to {
rotate: 360deg;
}
}