پیشنمایش زنده
کد HTML
<a href="#" class="kinetic-badge">
<div class="badge-bg"></div>
<div class="badge-text">
<svg viewBox="0 0 100 100" width="120" height="120">
<defs>
<path
id="circlePath"
d="M 50, 50 m -38, 0 a 38,38 0 1,1 76,0 a 38,38 0 1,1 -76,0"
></path>
</defs>
<text
font-size="10.5"
font-weight="600"
fill="currentColor"
letter-spacing="2"
>
<textPath href="#circlePath" startOffset="0%">
VIEW MASTERPIECE • VIEW MASTERPIECE •
</textPath>
</text>
</svg>
</div>
<div class="badge-icon">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
width="28"
height="28"
>
<path
d="M6 18L18 6M18 6H8M18 6V16"
stroke-width="2"
stroke-linejoin="round"
stroke-linecap="round"
></path>
</svg>
</div>
</a>
کد CSS
.loader {
} /* Bold editorial font */
@import url("s://fonts.googleapis.com/css2?family=Oswald:wght@500&display=swap");
.kinetic-badge {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 140px;
height: 140px;
text-decoration: none;
color: #1a1a1a;
font-family: "Oswald", sans-serif;
border-radius: 50%;
cursor: pointer;
}
/* The solid background that expands on hover */
.badge-bg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
width: 100%;
height: 100%;
background-color: #1a1a1a;
border-radius: 50%;
transition: transform 0.6s cubic-bezier(0.85, 0, 0.15, 1);
z-index: 1;
}
.kinetic-badge:hover .badge-bg {
transform: translate(-50%, -50%) scale(1);
}
/* The SVG Text Layer */
.badge-text {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
/* Endless slow rotation */
animation: spinSlow 10s linear infinite;
transition: color 0.4s ease;
}
.badge-text svg {
overflow: visible;
}
/* Smooth snap to white text on hover */
.kinetic-badge:hover .badge-text {
color: #f4f4f4;
/* Accelerate the spin */
animation: spinSlow 3s linear infinite;
}
/* The Center Icon */
.badge-icon {
position: relative;
z-index: 3;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.6s cubic-bezier(0.85, 0, 0.15, 1);
color: #1a1a1a;
}
/* Rotate and color-invert the arrow */
.kinetic-badge:hover .badge-icon {
transform: rotate(45deg) scale(1.2);
color: #f4f4f4;
}
/* Keyframes for the infinite text path rotation */
@keyframes spinSlow {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}