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

Sdílet
Vložit
  • čas přidán 28. 08. 2024
  • 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

Komentáře • 131

  • @kumarcodingzone
    @kumarcodingzone Před 7 měsíci +4

    Best Tutorial for Analog clock

  • @asifahmed6568
    @asifahmed6568 Před 6 měsíci +2

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

  • @ifeomablessing9578
    @ifeomablessing9578 Před 2 lety +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  Před 2 lety +1

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

    • @mdanas0007
      @mdanas0007 Před rokem +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  Před rokem

      @@mdanas0007 Thank you :)

    • @ossama_shaalan
      @ossama_shaalan Před 9 měsíci +1

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

    • @WebTechTalk
      @WebTechTalk  Před 9 měsíci

      @@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

  • @jodimccarthy7235
    @jodimccarthy7235 Před 4 dny +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  Před 2 dny

      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.

  • @mdtamzilsubhani7340
    @mdtamzilsubhani7340 Před rokem +6

    Bro all good but not functioning JavaScript

    • @WebTechTalk
      @WebTechTalk  Před rokem +1

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

  • @caracolinhos09
    @caracolinhos09 Před 2 lety +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  Před 2 lety

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

  • @wulja
    @wulja Před 6 měsíci +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  Před 6 měsíci

      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 Před měsícem +1

    Thanks for teaching us

  • @dhanush_gh
    @dhanush_gh Před rokem +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  Před rokem +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 Před 11 měsíci

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

  • @balenmohammed1657
    @balenmohammed1657 Před 2 lety +1

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety +1

      Another one interesting javascript program coming up soon 😀

  • @dhanjitkumarsingh7484
    @dhanjitkumarsingh7484 Před rokem +1

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

  • @khushbookhatwani9573
    @khushbookhatwani9573 Před 2 lety +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  Před 2 lety +1

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

  • @spencerhepworth6435
    @spencerhepworth6435 Před rokem +2

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

    • @WebTechTalk
      @WebTechTalk  Před rokem

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

  • @tanveershah8306
    @tanveershah8306 Před 2 lety +1

    very good approach sir for analog clock

  • @atulchavan2276
    @atulchavan2276 Před rokem +1

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

  • @rahulshaw6354
    @rahulshaw6354 Před 2 lety +1

    Very Nice and Easy Tutorial

  • @OnlyJesusMatters
    @OnlyJesusMatters Před rokem +1

    Thanks. Works well for me.

  • @suneelkumar-ju8up
    @suneelkumar-ju8up Před rokem +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  Před rokem

      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

  • @noor-e-sehar7316
    @noor-e-sehar7316 Před 3 měsíci +1

    It's really work

  • @EhllenQuezada
    @EhllenQuezada Před 3 měsíci

    What software are you using for this?

  • @Gvloves
    @Gvloves Před 5 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 5 měsíci +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 Před 5 měsíci

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

  • @b1studio648
    @b1studio648 Před 7 dny

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

    • @WebTechTalk
      @WebTechTalk  Před 7 dny

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

  • @SouravCheck
    @SouravCheck Před 4 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 3 měsíci

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

  • @Sitara934
    @Sitara934 Před 3 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 3 měsíci

      Sorry I didn't understand your question.

  • @therisingsun9745
    @therisingsun9745 Před 2 lety +2

    it was really beautiful bro ...loved it.

    • @WebTechTalk
      @WebTechTalk  Před 2 lety

      Thank you 😀

    • @therisingsun9745
      @therisingsun9745 Před 2 lety +1

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety

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

  • @user-rm1dj7sk4c
    @user-rm1dj7sk4c Před rokem +1

    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  Před rokem

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

    • @user-rm1dj7sk4c
      @user-rm1dj7sk4c Před rokem +1

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

    • @WebTechTalk
      @WebTechTalk  Před rokem

      @@user-rm1dj7sk4c Super

  • @lachidong7818
    @lachidong7818 Před 2 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 2 měsíci

      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".

  • @NATE-dq2uo
    @NATE-dq2uo Před rokem +1

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

    • @WebTechTalk
      @WebTechTalk  Před rokem

      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 Před rokem +1

    Great ! Thank You!

  • @Deveshhmaheshwari
    @Deveshhmaheshwari Před 8 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 8 měsíci

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

  • @burakfurkantenekeci7285
    @burakfurkantenekeci7285 Před 2 lety +3

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety +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 Před 2 lety +1

      @@WebTechTalk please can I have the code snippet?

    • @deslyatekendaya8671
      @deslyatekendaya8671 Před 2 lety +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  Před 2 lety

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety

      @@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.

  • @novakvelimirovic9865
    @novakvelimirovic9865 Před 2 lety +1

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety

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

  • @sreelakshmisasidharan9541

    Nice explanation 👏👍

  • @Shivamashish5236
    @Shivamashish5236 Před 2 lety +1

    Good one sir 👍🏻👍🏻

  • @UltimatePowerG0
    @UltimatePowerG0 Před rokem +1

    faboulous!

  • @jerade312
    @jerade312 Před 2 lety +1

    thanks for this bro

  • @balogunadenike2680
    @balogunadenike2680 Před rokem +1

    Thank you😇😇

  • @CoolHandLuke1117
    @CoolHandLuke1117 Před 7 měsíci

    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  Před 7 měsíci

      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 Před 7 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 7 měsíci

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

    • @CoolHandLuke1117
      @CoolHandLuke1117 Před 7 měsíci +1

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

    • @WebTechTalk
      @WebTechTalk  Před 7 měsíci +1

      @@CoolHandLuke1117 Sometimes this happens 😂

  • @leoocs1337
    @leoocs1337 Před 4 měsíci +1

    tysm!

  • @khushbookhatwani9573
    @khushbookhatwani9573 Před 2 lety +1

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety

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

  • @balenmohammed1657
    @balenmohammed1657 Před 2 lety +1

    GREAT JOB BRO

  • @suneelkumar-ju8up
    @suneelkumar-ju8up Před 2 lety +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  Před 2 lety

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

  • @faizulaleem348
    @faizulaleem348 Před rokem +1

    How to preview in Vs code?

    • @WebTechTalk
      @WebTechTalk  Před rokem

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

  • @khushbookhatwani9573
    @khushbookhatwani9573 Před 2 lety +1

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

    • @WebTechTalk
      @WebTechTalk  Před 2 lety

      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.

  • @aima-111
    @aima-111 Před rokem +1

    Where is the code link?

    • @WebTechTalk
      @WebTechTalk  Před rokem

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

  • @rabbad7228
    @rabbad7228 Před 10 měsíci

    Plz how you wrote fast html code in the first

    • @WebTechTalk
      @WebTechTalk  Před 10 měsíci

      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 Před 10 měsíci

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

    • @WebTechTalk
      @WebTechTalk  Před 10 měsíci

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

  • @prakash6485
    @prakash6485 Před 3 lety

    Very interesting bro

  • @S-Lomar
    @S-Lomar Před 11 měsíci +1

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

  • @AtSqureTech
    @AtSqureTech Před 22 dny

    #webtechtalk dear sir plz provide notes

    • @WebTechTalk
      @WebTechTalk  Před 21 dnem

      May I know which notes you are expecting?

  • @abhaykevat3997
    @abhaykevat3997 Před rokem +1

    please provide source code

    • @WebTechTalk
      @WebTechTalk  Před rokem

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

  • @solohitechnologys.h.t762
    @solohitechnologys.h.t762 Před 3 lety +1

    9ice 1

  • @hritikkumarshorts1290
    @hritikkumarshorts1290 Před 3 lety

    can uh plss provide the source code

    • @WebTechTalk
      @WebTechTalk  Před 3 lety

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

  • @SouravCheck
    @SouravCheck Před 3 měsíci

    really can't understand, dropping the video.

  • @dr.s.vatchala4571
    @dr.s.vatchala4571 Před měsícem

    Pdf