Creating a Basic Analog Clock with HTML, CSS, and JavaScript

Поділитися
Вставка
  • Опубліковано 9 лют 2025
  • Creating a Basic Analog Clock with HTML, CSS, and JavaScript
    Want to impress your friends with your coding skills? Look no further than this interactive analog clock tutorial using HTML, CSS, and JavaScript! In this beginner-friendly video, you'll learn how to:
    Craft the clock's structure with HTML: Lay the foundation with divs and spans, shaping the clock face, hands, and numbers.
    Make it shine with CSS: Breathe life into your clock with styles, adding colors, shadows, and elegant font choices.
    Bring it to life with JavaScript: Let the magic happen with JavaScript! We'll calculate hand rotations based on real-time, making your clock tick and tock with precision.
    By the end of this video, you'll have:
    A fully functional analog clock ticking away on your screen, a testament to your coding prowess.
    A deeper understanding of combining HTML, CSS, and JavaScript, opening doors to future creative projects.
    The satisfaction of building something beautiful and practical from scratch!
    No prior experience needed! This tutorial is perfect for anyone who wants to:
    Learn the basics of web development with fun, engaging projects.
    Add a touch of interactivity and personality to their web pages.
    Impress potential employers or clients with your coding skills.
    Click play and:
    Unleash your inner clockmaker! Build a stunning analog clock that's both beautiful and functional.
    Master the basics of HTML, CSS, and JavaScript in a practical and enjoyable way.
    Open the door to a world of creative possibilities with interactive web development.
    Don't wait! Start building your clock today!
    #javascript #clock #html #css #tutorial #beginnerfriendly #webdev #coding #interactive #analogclock
    If you're interested in exploring an Angular version, the provided link will direct you there. However, I strongly recommend watching this video first, as it provides a comprehensive explanation of the CSS and JavaScript logic.
    • Creating a Basic Analo...
    Thanks
    Creating a Basic Analog Clock with HTML, CSS, and JavaScript

КОМЕНТАРІ • 141

  • @asifahmed6568
    @asifahmed6568 11 місяців тому +3

    Absolutely amazing video and concisely explained. Thank you for sharing your knowledge with us

  • @kumarcodingzone
    @kumarcodingzone Рік тому +4

    Best Tutorial for Analog clock

  • @sahirulsekh1734
    @sahirulsekh1734 5 місяців тому +2

    You explained very simply. Thank you. Keep it up...

    • @WebTechTalk
      @WebTechTalk  5 місяців тому

      @@sahirulsekh1734 Thank you so much 🙏

  • @Bana-hukum-jaisalmer
    @Bana-hukum-jaisalmer Місяць тому

    aag laga di bhai, ek no

    • @WebTechTalk
      @WebTechTalk  Місяць тому

      @@Bana-hukum-jaisalmer please translate bro. Sorry 😐

    • @Bana-hukum-jaisalmer
      @Bana-hukum-jaisalmer Місяць тому +1

      @@WebTechTalk "Amazing, brother! Top-notch!" when my friend does some amazing things in his life i used to tell him "aag laga di bhai, ek no"

    • @WebTechTalk
      @WebTechTalk  Місяць тому

      @Bana-hukum-jaisalmer Thank you so much bro 😄

  • @balenmohammed1657
    @balenmohammed1657 2 роки тому +1

    Thanks a lot I got benefit from your Channel keep going and we are waiting for more projects in JavaScript

    • @WebTechTalk
      @WebTechTalk  2 роки тому +1

      Another one interesting javascript program coming up soon 😀

  • @wulja
    @wulja 11 місяців тому +1

    You did a great job. Could you give me a advice on how to fetch a PC-time from Windows and translate it to analog clock on the webpage so clock shows the time what its currently on your PC?

    • @WebTechTalk
      @WebTechTalk  11 місяців тому

      Hi this video is explaining how to show the PC time only (client time). To show server time we need a backend server.

  • @apk_academy
    @apk_academy 7 місяців тому +1

    Thanks for teaching us

  • @ifeomablessing9578
    @ifeomablessing9578 2 роки тому +6

    This is the best tutorial so far, it is so explanatory and the codes are very simple compared to some complex ones. you took time to explain the left and top values. I am subscribing right away

    • @WebTechTalk
      @WebTechTalk  2 роки тому +1

      Thank you very much. Your valuable comment motivates me a lot.

    • @mdanas0007
      @mdanas0007 2 роки тому +2

      Exactly bro there are many videos but they are complex for no reason.
      This is one is by far the best i have got.

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      @@mdanas0007 Thank you :)

    • @ossama_shaalan
      @ossama_shaalan Рік тому +1

      ​@@WebTechTalkI have an important question for me . Can I put the time from other countries in example Tokyo ar London

    • @WebTechTalk
      @WebTechTalk  Рік тому

      @@ossama_shaalan You can use the UI logic but in the place where you are getting the current time, you need to get the time from server or you need to add the relative GMT hours

  • @atulchavan2276
    @atulchavan2276 2 роки тому +1

    Thanks Mam..
    now it's working...

  • @dhanjitkumarsingh7484
    @dhanjitkumarsingh7484 2 роки тому +1

    Thank you so much sir. I really understand and able to make it. 💞

  • @tanveershah8306
    @tanveershah8306 2 роки тому +1

    very good approach sir for analog clock

  • @caracolinhos09
    @caracolinhos09 2 роки тому +2

    I put that code on the point , that 240 px on top and left but the point goes left , out of the clock, doesn´t stay in the midle , it just go to the midle if I put a value of 960 px on the left.

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      Could you please compare your code with mine. Here is my code.
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

  • @CabdiShakuur-s2e
    @CabdiShakuur-s2e 15 днів тому

    II wrote the code for the base.
    It’s not rotating, and I didn’t make any mistakes in the code.
    I’ve reviewed it multiple times.
    What should I do, teacher?
    🙏

    • @WebTechTalk
      @WebTechTalk  14 днів тому

      Please compare your code with mine. You can get my code from this repo.
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

  • @OnlyJesusMatters
    @OnlyJesusMatters 2 роки тому +1

    Thanks. Works well for me.

  • @UltimatePowerG0
    @UltimatePowerG0 2 роки тому +1

    faboulous!

  • @therisingsun9745
    @therisingsun9745 3 роки тому +2

    it was really beautiful bro ...loved it.

    • @WebTechTalk
      @WebTechTalk  3 роки тому

      Thank you 😀

    • @therisingsun9745
      @therisingsun9745 3 роки тому +1

      @@WebTechTalk bro if you want you can teach me js, i will pay you.

    • @WebTechTalk
      @WebTechTalk  3 роки тому

      I will be starting the Javascript Series soon. Don't worry

  • @rahulshaw6354
    @rahulshaw6354 2 роки тому +1

    Very Nice and Easy Tutorial

  • @mdtamzilsubhani7340
    @mdtamzilsubhani7340 Рік тому +6

    Bro all good but not functioning JavaScript

    • @WebTechTalk
      @WebTechTalk  Рік тому +2

      You can compare your code with mine bro.
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

  • @dhanush_gh
    @dhanush_gh 2 роки тому +2

    Thank you so much, but you should have also showed how to get perfect number for hour placement (like example- hour 9 : top 235px, left 45px )? , Other than that awesome video 😊👍🏽👍🏽

    • @WebTechTalk
      @WebTechTalk  2 роки тому +1

      Those numbers I got it from the inspect window only. I adjusted by placing them randomly and took the values.

    • @S-Lomar
      @S-Lomar Рік тому

      And how to earn on it💕💕💕💓💓💓💓🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰🥰😍😍🥰🥰🥰🥰🥰🥰🥰🥰🥰

  • @shish5236
    @shish5236 2 роки тому +1

    Good one sir 👍🏻👍🏻

  • @NATE-dq2uo
    @NATE-dq2uo Рік тому +1

    I like this vid and I tried it
    I just want to know how to move the HOUR HAND?

    • @WebTechTalk
      @WebTechTalk  Рік тому

      Every second I am getting the current time and calculating the position of each hands. For example: Hour hand logic is d.getHours() * 30 + Math.round(minute / 12)

  • @rutvikbhoj4737
    @rutvikbhoj4737 2 роки тому +1

    Great ! Thank You!

  • @noor-e-sehar7316
    @noor-e-sehar7316 8 місяців тому +1

    It's really work

  • @ЕвгенийГончаров-ъ2я

    hi, friend! i have a problem. When my second line is going to 12 pm, it make return back but have to go ahead in circle. What can i do for resolve this problem.

    • @WebTechTalk
      @WebTechTalk  Рік тому

      Please compare your code with mine.
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

    • @ЕвгенийГончаров-ъ2я
      @ЕвгенийГончаров-ъ2я Рік тому +1

      @@WebTechTalk thanks, I've found mistake. My program is working

    • @WebTechTalk
      @WebTechTalk  Рік тому

      @@ЕвгенийГончаров-ъ2я Super

  • @balogunadenike2680
    @balogunadenike2680 2 роки тому +1

    Thank you😇😇

  • @SouravCheck
    @SouravCheck 9 місяців тому

    Please write the commands also which you used for preview and other things so that we can follow along

    • @WebTechTalk
      @WebTechTalk  9 місяців тому

      Sure. I will do this in future videos. I don't remember whether I have used any command in this video.

  • @jodimccarthy7235
    @jodimccarthy7235 5 місяців тому +1

    Could we add code to run the clock faster or slower - I wish to create an alternate reality that has time that runs a bit faster - a specific value 5 points past the decimal point

    • @WebTechTalk
      @WebTechTalk  5 місяців тому

      This clock is using the current system time and so we cannot make it run fast or slower. We may need to change the core logic.

  • @khushbookhatwani9573
    @khushbookhatwani9573 2 роки тому +2

    also in rotate you have done transform rotate(second +deg ).I am little confused is deg a variable or constatnt in this

    • @WebTechTalk
      @WebTechTalk  2 роки тому +1

      deg is the unit. We have to give that inside rotate. deg means degree. Eg: transform: rotate(60deg)

  • @sreelakshmisasidharan9541
    @sreelakshmisasidharan9541 4 роки тому +1

    Nice explanation 👏👍

  • @suneelkumar-ju8up
    @suneelkumar-ju8up Рік тому +1

    Hi I'm facing issue with respect to my project work and the client is expecting for performance improvement, in angular 12 I am getting blocked for the project .

    • @WebTechTalk
      @WebTechTalk  Рік тому

      There are many ways by which you can improve the performance in angular applications. Follow the best practices and see whether you need to concentrate more on the web vitals part or API side. In UI side, you can think about implementing caching of static resources, text compression, etc

  • @spencerhepworth6435
    @spencerhepworth6435 2 роки тому +2

    How did you run the calculations to know exactly where to place the numbers within the clock?

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      It is purely kind of trial and error. I inspect it and adjust the position and found the top, right and left values.

  • @balenmohammed1657
    @balenmohammed1657 2 роки тому +1

    GREAT JOB BRO

  • @jerade312
    @jerade312 2 роки тому +1

    thanks for this bro

  • @Horria-r2b
    @Horria-r2b 9 місяців тому

    Mam kia ya clock user screen pr kis trha lga skty??? Have any idea plz give me

    • @WebTechTalk
      @WebTechTalk  9 місяців тому

      Sorry I didn't understand your question.

  • @EhllenQuezada
    @EhllenQuezada 9 місяців тому

    What software are you using for this?

    • @WebTechTalk
      @WebTechTalk  9 місяців тому

      For recording and editing?

  • @lachidong7818
    @lachidong7818 7 місяців тому

    how did you do the math to add up top left ?

    • @WebTechTalk
      @WebTechTalk  7 місяців тому

      I believe you are asking about the position values to place the hour numbers in the clock. That is totally trial and error. I have already tried and while recording I used those values. That is why I have mentioned that "I have also found the right values".

  • @Gvloves
    @Gvloves 10 місяців тому

    How to open the preview in vs code , and also m following your steps but it's not working properly,

    • @WebTechTalk
      @WebTechTalk  10 місяців тому +1

      There are many extensions available. Eg: Live Preview. I used that. You can compare your code with mine. Check this repo for my code: github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

    • @Gvloves
      @Gvloves 10 місяців тому

      @@WebTechTalk thank you very much it's really helpful

  • @vwpe
    @vwpe 10 місяців тому +1

    tysm!

  • @burakfurkantenekeci7285
    @burakfurkantenekeci7285 2 роки тому +3

    Great work bro. But how you calculated the left and top values of hours?

    • @WebTechTalk
      @WebTechTalk  2 роки тому +1

      Thanks bro. Those left, right and top values are approximate values. Got it by trial and error adjustment. For example, if you see the dial width is 500px, so, to place 12 in the center, we need to use 250px minus some width for the text size. So 235px is what it came right. But for 6, 240px is fine because it is a single digit. Like that I found for all hours.

    • @deslyatekendaya8671
      @deslyatekendaya8671 2 роки тому +1

      @@WebTechTalk please can I have the code snippet?

    • @deslyatekendaya8671
      @deslyatekendaya8671 2 роки тому +2

      @@WebTechTalk I want to add letters outside the clock that link to words from instance outside the 12 I put AB ,A stands for about us and B stands for book now...

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      @@deslyatekendaya8671 Sure. You can get it from this location.
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      @@deslyatekendaya8671 Sorry. I didn't understand your requirement clearly. If you want to add more text outside the clock, you can add a wrapper and position that relatively.

  • @suneelkumar-ju8up
    @suneelkumar-ju8up 2 роки тому +2

    Hi your videos are interesting, can you make a common repository where we can have references for the concepts dt u delivered

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      You can get it from this repo.
      github.com/freelancer-surender/Misc

  • @faizulaleem348
    @faizulaleem348 2 роки тому +1

    How to preview in Vs code?

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      You can use some extensions like LiveServer. There are many.

  • @nolevelli
    @nolevelli 2 роки тому +1

    Expression expected, and ';' expected. is errors i get when i type this index file

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      Please compare your code with mine.
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

  • @prakash6485
    @prakash6485 4 роки тому

    Very interesting bro

  • @KhwaishSaini-b3b
    @KhwaishSaini-b3b 5 місяців тому

    Is this Clock is responsive or not??

    • @WebTechTalk
      @WebTechTalk  5 місяців тому +1

      I think I have not applied code to make this responsive.

  • @b1studio648
    @b1studio648 5 місяців тому

    are you teaching or speedrunning it? why dont u make it a bit slow?

    • @WebTechTalk
      @WebTechTalk  5 місяців тому

      @@b1studio648 yes my initial days videos are fast. Sorry.

  • @CoolHandLuke1117
    @CoolHandLuke1117 Рік тому

    I can't get the hands to move. Everything is in there exactly like you have. Not sure why they aren't moving.

    • @WebTechTalk
      @WebTechTalk  Рік тому

      Please check for any JavaScript error in the browser console. Or, you can compare with my code. My code is available in the git.

    • @CoolHandLuke1117
      @CoolHandLuke1117 Рік тому

      @@WebTechTalk Correct. Is there anything else needed like a special JSON or anthing to be linked?

    • @WebTechTalk
      @WebTechTalk  Рік тому

      @@CoolHandLuke1117 No. Please check this repo for code. github.com/freelancer-surender/Misc

    • @CoolHandLuke1117
      @CoolHandLuke1117 Рік тому +1

      @@WebTechTalk You are not going to believe this..I forgot my in javascript 😝. Thank you so much for troubleshooting with me

    • @WebTechTalk
      @WebTechTalk  Рік тому +1

      @@CoolHandLuke1117 Sometimes this happens 😂

  • @rabbad7228
    @rabbad7228 Рік тому

    Plz how you wrote fast html code in the first

    • @WebTechTalk
      @WebTechTalk  Рік тому

      This is called Emmet. I think VSCode by default support this. There are also some extensions available. You can search for HTML Boilerplate, HTML Snippets

    • @rabbad7228
      @rabbad7228 Рік тому

      @@WebTechTalk i mean did you wrote a one letter in short way and press enter?

    • @WebTechTalk
      @WebTechTalk  Рік тому

      @@rabbad7228 Yes, in VS Code if you type html:5 and press enter it will create the boilerplate code

  • @khushbookhatwani9573
    @khushbookhatwani9573 2 роки тому +1

    Also i am unable to open source code given in one of the comment by you

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      Please use this link
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

  • @aima-111
    @aima-111 2 роки тому +1

    Where is the code link?

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      You can get the code from this repo.
      github.com/freelancer-surender/Misc

  • @khushbookhatwani9573
    @khushbookhatwani9573 2 роки тому +1

    can anybody explain the logic elaborately of math.round(minutes/12)

    • @WebTechTalk
      @WebTechTalk  2 роки тому

      That is to add precision. When the time is 3PM, the hour hand will be exactly in 3. But when the time is 3:40PM, the hour hand will be somewhere between 3 and 4. So, to add that precision I am just adding that. If you see, I have multiplied seconds and minutes by 6 and hours by 30. That is because, the entire dial is going to be 360 degree. There are 60 seconds and so 360/60 = 6. Same for minute hand. But for hour, we have to divide the dial into 12 parts, that means 360/12 = 30. Plus the precision which is (minutes * 30) / 360 = minutes / 12. And then finally I am rounding that to the nearest number. Hope it is clear.

  • @S-Lomar
    @S-Lomar Рік тому +1

    💕💕💕🤣😍😍🥰🥰🥰🥰🥰🥰🥰🥰💓💕💕💕💕💕💕💕💕💕💕 thank you for sharing your experience

  • @Deveshhmaheshwari
    @Deveshhmaheshwari Рік тому

    what was the logic of hours *30 when hours are only 24? why not *24 or *12

    • @WebTechTalk
      @WebTechTalk  Рік тому

      The clock dial is totally 360 degrees. So, 360 divided by 12 hours gives us 30 degrees for each hour. That is why 30.

  • @abhaykevat3997
    @abhaykevat3997 Рік тому +1

    please provide source code

    • @WebTechTalk
      @WebTechTalk  Рік тому

      You can get it from here
      github.com/freelancer-surender/Misc/tree/main/Analog%20Clock

  • @solohitechnologys.h.t762
    @solohitechnologys.h.t762 3 роки тому +1

    9ice 1

  • @AtSqureTech
    @AtSqureTech 6 місяців тому

    #webtechtalk dear sir plz provide notes

    • @WebTechTalk
      @WebTechTalk  6 місяців тому

      May I know which notes you are expecting?

  • @hritikkumarshorts1290
    @hritikkumarshorts1290 3 роки тому

    can uh plss provide the source code

    • @WebTechTalk
      @WebTechTalk  3 роки тому

      Yes sure. github.com/freelancer-surender/analog-clock

  • @SouravCheck
    @SouravCheck 9 місяців тому

    really can't understand, dropping the video.

  • @dr.s.vatchala4571
    @dr.s.vatchala4571 7 місяців тому

    Pdf