Apply CSS animation to SVG circle
by Hugo Lopez
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Spinner Animation</title>
<style>
/* Full-screen center alignment */
body, html {
margin: 0;
padding: 0;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
background: #ffffff;
}
/* Spinner styles */
.spinner {
width: 80px;
height: 80px;
animation: rotate15 1s steps(24) infinite;
transform-origin: 50% 50%;
}
/* 45° step rotation */
@keyframes rotate15 {
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<svg class="spinner" viewBox="0 0 100 100">
<circle id="circle" cx="50" cy="50" r="40" stroke="#ccc" stroke-width="10" fill="none" />
<path id="arc" stroke="#007BFF" stroke-width="10" fill="none" stroke-linecap="round"
d="M50,10 A40,40 0 0,1 90,50" />
</svg>
</body>
</html>