View raw output
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Analog Clock</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: #1a1a1a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.clock-container {
position: relative;
}
.clock {
width: 350px;
height: 350px;
background-color: #ffffff;
border: 12px solid #333333;
border-radius: 50%;
position: relative;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 0, 0, 0.2);
}
/* Clock Center Nut */
.clock::before {
content: '';
position: absolute;
width: 16px;
height: 16px;
background-color: #2c3e50;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
/* Numbers */
.number {
position: absolute;
width: 100%;
height: 100%;
text-align: center;
transform-origin: center center;
font-size: 1.5rem;
font-weight: 700;
color: #2c3e50;
padding: 10px;
}
.number span {
display: inline-block;
transform-origin: center center;
}
/* Hands */
.hand {
position: absolute;
bottom: 50%;
left: 50%;
transform-origin: bottom center;
border-radius: 5px;
transition: transform 0.05s cubic-bezier(0.1, 2.7, 0.58, 1);
}
.hour-hand {
width: 8px;
height: 25%;
background-color: #2c3e50;
margin-left: -4px;
z-index: 7;
}
.minute-hand {
width: 5px;
height: 38%;
background-color: #34495e;
margin-left: -2.5px;
z-index: 8;
}
.second-hand {
width: 2px;
height: 45%;
background-color: #e74c3c;
margin-left: -1px;
z-index: 9;
transition: none; /* Continuous smooth motion */
}
/* Tail of the second hand */
.second-hand::after {
content: '';
position: absolute;
bottom: -20px;
left: 50%;
width: 2px;
height: 20px;
background-color: #e74c3c;
margin-left: -1px;
}
/* Ticks */
.tick {
position: absolute;
width: 2px;
height: 10px;
background-color: #bdc3c7;
left: 50%;
top: 0;
transform-origin: center 163px; /* 175px (half of 350) minus border(12) = 163 */
margin-left: -1px;
}
.tick.major {
width: 4px;
height: 20px;
background-color: #2c3e50;
margin-left: -2px;
}
</style>
</head>
<body>
<div class="clock-container">
<div class="clock" id="clock">
<!-- Numbers will be inserted here by JavaScript -->
<!-- Hands -->
<div class="hand hour-hand" id="hour-hand"></div>
<div class="hand minute-hand" id="minute-hand"></div>
<div class="hand second-hand" id="second-hand"></div>
</div>
</div>
<script>
const clock = document.getElementById('clock');
const hourHand = document.getElementById('hour-hand');
const minuteHand = document.getElementById('minute-hand');
const secondHand = document.getElementById('second-hand');
// Generate Numbers 1-12 and Ticks
for (let i = 1; i <= 60; i++) {
// Create ticks
const tick = document.createElement('div');
tick.classList.add('tick');
tick.style.transform = `rotate(${i * 6}deg)`;
if (i % 5 === 0) {
tick.classList.add('major');
// Create Numbers
const numberIndex = i / 5;
const number = document.createElement('div');
number.classList.add('number');
number.style.transform = `rotate(${i * 6}deg)`;
const span = document.createElement('span');
span.textContent = numberIndex;
// Counter-rotate the text so it stays upright
span.style.transform = `rotate(-${i * 6}deg)`;
number.appendChild(span);
clock.appendChild(number);
}
clock.appendChild(tick);
}
// Update the clock face
function updateClock() {
const now = new Date();
const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();
const milliseconds = now.getMilliseconds();
// Calculate degrees (adding milliseconds/seconds fractions for smooth continuous motion)
const secondsDeg = ((seconds + milliseconds / 1000) / 60) * 360;
const minutesDeg = ((minutes + seconds / 60) / 60) * 360;
const hoursDeg = (((hours % 12) + minutes / 60) / 12) * 360;
secondHand.style.transform = `rotate(${secondsDeg}deg)`;
minuteHand.style.transform = `rotate(${minutesDeg}deg)`;
hourHand.style.transform = `rotate(${hoursDeg}deg)`;
requestAnimationFrame(updateClock);
}
// Start the clock
requestAnimationFrame(updateClock);
</script>
</body>
</html>
```