Digital Clock
HTML CODE:-
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <body> <div class="container"> <span id="hrs">00</span> <span>:</span> <span id="min">00</span> <span>:</span> <span id="sec">00</span> </div> </body> </html> |
CSS CODE:-
body{ padding: 0px; margin: 0px; display: flex; align-items: center; justify-content: center; min-height: 100vh; background-image:linear-gradient(rgba(0,0,0,0.8),rgba(0,0,0,0.8)), url("https://media.istockphoto.com/id/1478284696/photo/happy-easter-with-tulips-and-decorative-eggs-in-various-colors.jpg?s=612x612&w=0&k=20&c=AevfQOzjK87fMa2pnS4hyU7oG4M89f6V3gYP45luZzg="); background-size: cover; } .container{ display: inline-block; position: relative; width: 250px; height: 70px; text-align: center; line-height: 70px; color: white; border-radius: 10px; background-image:linear-gradient(rgba(0,0,0,0.7),rgba(0,0,0,0.7)); border: 2px solid white; font-size: 30px; } |
JS CODE:-
let hrs = document.getElementById("hrs"); let min = document.getElementById("min"); let sec = document.getElementById("sec"); setInterval(()=>{ let curtime = new Date(); hrs.innerHTML = curtime.getHours(); min.innerHTML = curtime.getMinutes(); sec.innerHTML = curtime.getSeconds(); },1000) |