پیشنمایش زنده
کد HTML
<button class="button">
<p class="button__text">
<span style="--index: 0;">T</span>
<span style="--index: 1;">W</span>
<span style="--index: 2;">I</span>
<span style="--index: 3;">T</span>
<span style="--index: 4;">T</span>
<span style="--index: 5;">E</span>
<span style="--index: 6;">R</span>
<span style="--index: 7;"> </span>
<span style="--index: 8;">T</span>
<span style="--index: 9;">W</span>
<span style="--index: 10;">I</span>
<span style="--index: 11;">T</span>
<span style="--index: 12;">T</span>
<span style="--index: 13;">E</span>
<span style="--index: 14;">R</span>
</p>
<div class="button__circle">
<svg
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="button__icon"
width="25"
>
<path
d="M5.026 15c6.038 0 9.341-5.003 9.341-9.334 0-.14 0-.282-.006-.422A6.685 6.685 0 0 0 16 3.542a6.658 6.658 0 0 1-1.889.518 3.301 3.301 0 0 0 1.447-1.817 6.533 6.533 0 0 1-2.087.793A3.286 3.286 0 0 0 7.875 6.03a9.325 9.325 0 0 1-6.767-3.429 3.289 3.289 0 0 0 1.018 4.382A3.323 3.323 0 0 1 .64 6.575v.045a3.288 3.288 0 0 0 2.632 3.218 3.203 3.203 0 0 1-.865.115 3.23 3.23 0 0 1-.614-.057 3.283 3.283 0 0 0 3.067 2.277A6.588 6.588 0 0 1 .78 13.58a6.32 6.32 0 0 1-.78-.045A9.344 9.344 0 0 0 5.026 15z"
fill="currentColor"
></path>
</svg>
<svg
viewBox="0 0 16 16"
fill="none"
width="25"
xmlns="http://www.w3.org/2000/svg"
class="button__icon button__icon--copy"
>
<path
d="M5.026 15c6.038 0 9.341-5.003 9.341-9.334 0-.14 0-.282-.006-.422A6.685 6.685 0 0 0 16 3.542a6.658 6.658 0 0 1-1.889.518 3.301 3.301 0 0 0 1.447-1.817 6.533 6.533 0 0 1-2.087.793A3.286 3.286 0 0 0 7.875 6.03a9.325 9.325 0 0 1-6.767-3.429 3.289 3.289 0 0 0 1.018 4.382A3.323 3.323 0 0 1 .64 6.575v.045a3.288 3.288 0 0 0 2.632 3.218 3.203 3.203 0 0 1-.865.115 3.23 3.23 0 0 1-.614-.057 3.283 3.283 0 0 0 3.067 2.277A6.588 6.588 0 0 1 .78 13.58a6.32 6.32 0 0 1-.78-.045A9.344 9.344 0 0 0 5.026 15z"
fill="currentColor"
></path>
</svg>
</div>
</button>
کد CSS
.button {
cursor: pointer;
border: none;
background: #00ccff;
color: #fff;
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(22deg * var(--index)));
inset: 7px;
}
}
.button__circle {
position: relative;
width: 40px;
height: 40px;
overflow: hidden;
background: #212121;
color: #00ccff;
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: #fff;
}
.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;
}
}
.button:active {
transform: scale(0.95);
}