jdobry

Untitled

Feb 26th, 2026
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.05 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Analog Clock</title>
  7. <style>
  8. body {
  9. margin: 0;
  10. padding: 0;
  11. display: flex;
  12. justify-content: center;
  13. align-items: center;
  14. height: 100vh;
  15. background-color: #ffffff;
  16. font-family: Arial, sans-serif;
  17. }
  18.  
  19. .clock {
  20. width: 300px;
  21. height: 300px;
  22. border: 10px solid #333;
  23. border-radius: 50%;
  24. position: relative;
  25. background-color: #fff;
  26. box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  27. }
  28.  
  29. .hand {
  30. position: absolute;
  31. bottom: 50%;
  32. left: 50%;
  33. transform-origin: bottom center;
  34. background-color: #333;
  35. border-radius: 50% 50% 0 0;
  36. transform: translateX(-50%);
  37. z-index: 10;
  38. }
  39.  
  40. .hour {
  41. width: 6px;
  42. height: 80px;
  43. }
  44.  
  45. .minute {
  46. width: 4px;
  47. height: 100px;
  48. background-color: #666;
  49. }
  50.  
  51. .second {
  52. width: 2px;
  53. height: 110px;
  54. background-color: #d32f2f;
  55. z-index: 20;
  56. }
  57.  
  58. .center-dot {
  59. width: 16px;
  60. height: 16px;
  61. background-color: #333;
  62. border-radius: 50%;
  63. position: absolute;
  64. top: 50%;
  65. left: 50%;
  66. transform: translate(-50%, -50%);
  67. z-index: 30;
  68. }
  69.  
  70. .marker {
  71. position: absolute;
  72. width: 4px;
  73. height: 10px;
  74. background-color: #333;
  75. left: 50%;
  76. transform: translateX(-50%);
  77. }
  78.  
  79. .marker[data-hour="12"] { top: 15px; }
  80. .marker[data-hour="3"] { top: 50%; right: 15px; transform: rotate(90deg) translateX(0); transform-origin: center; }
  81. .marker[data-hour="6"] { bottom: 15px; }
  82. .marker[data-hour="9"] { top: 50%; left: 15px; transform: rotate(-90deg) translateX(0); transform-origin: center; }
  83.  
  84. .marker:nth-child(2) { top: 15px; } /* 12 */
  85. .marker:nth-child(3) { right: 15px; top: 50%; transform: rotate(90deg); } /* 3 */
  86. .marker:nth-child(4) { bottom: 15px; } /* 6 */
  87. .marker:nth-child(5) { left: 15px; top: 50%; transform: rotate(-90deg); } /* 9 */
  88.  
  89. /* Additional small markers */
  90. .clock::before {
  91. content: '';
  92. position: absolute;
  93. width: 100%;
  94. height: 100%;
  95. border-radius: 50%;
  96. z-index: 0;
  97. }
  98.  
  99. .clock:hover {
  100. cursor: pointer;
  101. box-shadow: 0 15px 30px rgba(0,0,0,0.15);
  102. }
  103.  
  104. </style></head>
  105. <body>
  106.  
  107. <div class="clock">
  108. <div class="marker"></div>
  109. <div class="marker"></div>
  110. <div class="marker"></div>
  111. <div class="marker"></div>
  112. <div class="hand hour" id="hourHand"></div>
  113. <div class="hand minute" id="minuteHand"></div>
  114. <div class="hand second" id="secondHand"></div>
  115. <div class="center-dot"></div>
  116. </div>
  117.  
  118. <script>
  119. function updateClock() {
  120. const now = new Date();
  121. const hours = now.getHours();
  122. const minutes = now.getMinutes();
  123. const seconds = now.getSeconds();
  124.  
  125. const hourDeg = (hours % 12) * 30 + minutes * 0.5;
  126. const minuteDeg = minutes * 6 + seconds * 0.1;
  127. const secondDeg = seconds * 6;
  128.  
  129. document.getElementById('hourHand').style.transform = `translateX(-50%) rotate(${hourDeg}deg)`;
  130. document.getElementById('minuteHand').style.transform = `translateX(-50%) rotate(${minuteDeg}deg)`;
  131. document.getElementById('secondHand').style.transform = `translateX(-50%) rotate(${secondDeg}deg)`;
  132. }
  133.  
  134. setInterval(updateClock, 1000);
  135. updateClock(); // Initial call
  136. </script></body>
  137. </html>
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
Advertisement
Add Comment
Please, Sign In to add comment