Animated speedometer-style gauge with rotating needle. Perfect for dashboards, analytics, or displaying metrics in a visual way.
<div class="gauge">
<div class="gauge-needle"></div>
</div>
.gauge {
width: 120px;
height: 60px;
border: 4px solid #667eea;
border-bottom: none;
border-radius: 120px 120px 0 0;
position: relative;
overflow: hidden;
}
.gauge::before {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 12px;
height: 12px;
background: #667eea;
border-radius: 50%;
z-index: 2;
}
.gauge-needle {
position: absolute;
bottom: 0;
left: 50%;
width: 4px;
height: 50px;
background: linear-gradient(to top, #667eea, #764ba2);
transform-origin: bottom center;
animation: gaugeSwing 3s ease-in-out infinite;
border-radius: 2px;
}
@keyframes gaugeSwing {
0%, 100% {
transform: translateX(-50%) rotate(-60deg);
}
50% {
transform: translateX(-50%) rotate(60deg);
}
}