Solution: Neumorphism Analog Clock using HTML, CSS & JavaScript with source code, demo, and also how you can execute full program easily. To complete the program you need to follow those steps given bellow
Live Demo
Also Helpful –
Neumorphism Analog Clock using HTML, CSS & JavaScript
Hi
Back to coding, To complete this program with debugging free code you have to create three files. The first file is to HTML and the second file gonna be CSS for design part and the third file JavaScript for function-related,
index.html
Create an HTML file named ‘index.html‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<!-- Coding Debugging (https://codingdebugging.com) --> <!DOCTYPE html> <html> <head> <title>Neumorphism Analog Clock - Coding Debugging</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- My Stylesheet --> <link rel="stylesheet" href="style.css"> </head> <body> <div class="clock"> <div class="center-nut"></div> <div class="center-nut2"></div> <div class="indicators"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <div class="sec-hand"> <div class="sec"></div> </div> <div class="min-hand"> <div class="min"></div> </div> <div class="hr-hand"> <div class="hr"></div> </div> </div> <!-- JavaScript Page --> <script src="function.js" type="text/javascript"></script> </body> </html> |
style.css
Create a CSS file named ‘style.css‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
*{ margin: 0; padding: 0; box-sizing: border-box; } html,body{ height: 100%; } body{ display: grid; place-items: center; background: #dde1e7; text-align: center; } .clock{ position: relative; display: flex; align-items: center; justify-content: center; background: #dde1e7; height: 250px; width: 250px; border-radius: 50%; box-shadow: -3px -3px 7px #ffffff73, 3px 3px 5px rgba(94,104,121,0.288); } .clock:before{ position: absolute; content: ''; height: 220px; width: 220px; background: #dde1e7; border-radius: 50%; box-shadow: inset -3px -3px 7px #ffffff73, inset 3px 3px 5px rgba(94,104,121,0.288); } .clock:after{ position: absolute; content: ''; height: 120px; width: 120px; background: #dde1e7; border-radius: 50%; box-shadow: -1px -1px 5px #ffffff73, 1px 1px 3px rgba(94,104,121,0.288); } .clock .center-nut{ height: 15px; width: 15px; background: #404040; border-radius: 50%; z-index: 2; position: absolute; } .clock .center-nut2{ height: 9px; width: 9px; background: #3498db; border-radius: 50%; z-index: 15; position: absolute; } .indicators div{ position: absolute; width: 2px; height: 5px; background: #404040; } .indicators div:nth-child(1){ transform: rotate(30deg) translateY(-100px); } .indicators div:nth-child(2){ transform: rotate(60deg) translateY(-100px); } .indicators div:nth-child(3){ background: #3498db; transform: rotate(90deg) translateY(-100px); } .indicators div:nth-child(4){ transform: rotate(120deg) translateY(-100px); } .indicators div:nth-child(5){ transform: rotate(150deg) translateY(-100px); } .indicators div:nth-child(6){ background: #3498db; transform: rotate(180deg) translateY(-100px); } .indicators div:nth-child(7){ transform: rotate(210deg) translateY(-100px); } .indicators div:nth-child(8){ transform: rotate(240deg) translateY(-100px); } .indicators div:nth-child(9){ background: #3498db; transform: rotate(270deg) translateY(-100px); } .indicators div:nth-child(10){ transform: rotate(300deg) translateY(-100px); } .indicators div:nth-child(11){ transform: rotate(330deg) translateY(-100px); } .indicators div:nth-child(12){ background: #3498db; transform: rotate(360deg) translateY(-100px); } .sec-hand,.min-hand,.hr-hand{ position: absolute; } .sec-hand, .sec{ height: 180px; width: 180px; z-index: 6; } .min-hand, .min{ height: 140px; width: 140px; z-index: 5; } .hr-hand, .hr{ height: 110px; width: 110px; z-index: 4; } .sec,.min,.hr{ display: flex; justify-content: center; position: absolute; } .sec:before{ position: absolute; content: ''; height: 110px; width: 3px; background: #3498db; } .sec:after{ position: absolute; content: ''; height: 35px; width: 7px; background: #3498db; top: 105px; border-radius: 5px; } .min:before{ position: absolute; content: ''; width: 1px; top: -15px; border-left: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 60px solid #e95949; } .min:after{ position: absolute; content: ''; width: 3px; top: 40px; border-left: 2px solid transparent; border-right: 2px solid transparent; border-top: 30px solid #e95949; } .hr:before{ position: absolute; content: ''; width: 1px; border-left: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 35px solid #303030; } .hr:after{ position: absolute; content: ''; width: 3px; top: 34px; border-left: 2px solid transparent; border-right: 2px solid transparent; border-top: 25px solid #303030; } |
function.js
Create a JavaScript file named ‘function.js‘ and put those codes given below.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
const sec = document.querySelector(".sec"); const min = document.querySelector(".min"); const hr = document.querySelector(".hr"); setInterval(function(){ let time = new Date(); let secs = time.getSeconds() * 6; let mins = time.getMinutes() * 6; let hrs = time.getHours() * 30; sec.style.transform = `rotateZ(${secs}deg)`; min.style.transform = `rotateZ(${mins}deg)`; hr.style.transform = `rotateZ(${hrs+(mins/12)}deg)`; }); |
Thank you for visiting!
We appreciate you for your precious time. I hope you are learn something from here! If you have any queries about this coding comment down below we will reply ASAP.
Keep coding, Keep debugging!