By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
rocoderesrocoderes
  • Home
  • HTML & CSS
    • Login and Registration Form
    • Card Design
    • Loader
  • JavaScript
  • Python
  • Internet
  • Landing Pages
  • Tools
    • Google Drive Direct Download Link Generator
    • Word Count
  • Games
    • House Painter
Notification Show More
Latest News
How to set the dropdown value by clicking on a table row
Javascript – How to set the dropdown value by clicking on a table row
JavaScript
Attempting to increase the counter, when the object's tag exist
Javascript – Attempting to increase the counter, when the object’s tag exist
JavaScript
Cycle2 JS center active slide
Javascript – Cycle2 JS center active slide
JavaScript
Can import all THREE.js post processing modules as ES6 modules except OutputPass
Javascript – Can import all THREE.js post processing modules as ES6 modules except OutputPass
JavaScript
How to return closest match for an array in Google Sheets Appscript
Javascript – How to return closest match for an array in Google Sheets Appscript
JavaScript
Aa
Aa
rocoderesrocoderes
Search
  • Home
  • HTML & CSS
    • Login and Registration Form
    • Card Design
    • Loader
  • JavaScript
  • Python
  • Internet
  • Landing Pages
  • Tools
    • Google Drive Direct Download Link Generator
    • Word Count
  • Games
    • House Painter
Follow US
High Quality Design Resources for Free.
rocoderes > HTML & CSS > Loader > How to Make Clock Loader Using CSS
HTML & CSSLoader

How to Make Clock Loader Using CSS

Admin
Last updated: 2022/12/02 at 4:45 AM
Admin
Share
6 Min Read
Clock Loader Using CSS fidget spinner loader

In this article, we will make clock loader using CSS. This is going to be a basic and beginner-friendly project, as all of our loader project are basic. So here, we will have a clock with two hands, and these hands spins infinitely. Adding this kind of loader will be very much cool if you’re planning to add loader in your website or something.

Contents
Pre-requisites to Make Clock Loader Using CSSCreating HTML Markup Adding Center of ClockAdding Hands to Clock CenterAdding Animation to HandsFull Source Code To Make Clock Loader Using CSSOutput
Demo

Pre-requisites to Make Clock Loader Using CSS

  • Basic knowledge of HTML.
  • Basic knowledge of CSS and CSS animations.

Creating HTML Markup

<!DOCTYPE html>
<html>
    <head>
        <title>Clock Loader</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <div class="clock">
            <div class="center"></div>
            <div class="hand1"></div>
            <div class="hand2"></div>
        </div>
    </body>

</html>
body{
    margin: 0;
    padding: 0;
    background-color: #ffff4d;
}

First of all in HTML, we have added a div for clock which have another three divs for center of clock and other twos for hands. Now in CSS, we have reset our default margin and padding to 0 with #ffff4dcolor.

Adding Center of Clock

.clock{
    position: absolute;
    top: 43%;
    left: 43%;
    height: 120px;
    width: 120px;
    background-color: white;
    border-radius: 50%;
    border: 6px solid #5c5c8a;
}

.center{
    position: relative;
    background-color: tomato;
    height: 15px;
    width: 15px;
    border-radius: 50%;
    top: 52px;
    left: 52px;
}

Now let’s form the clock, and it’s center, for that we have added some height and width to the clock, and we have adjusted its position using top and left property. Then we have added absolute position so that it won’t get moved when we add something to it, and it will get fixed on that position. After that, we have gave white background to the clock, and also we gave it round shape using border-radius property. Finally, we have also added some border to it.

For the center, we have added some height and width with background color tomato. Also, we have it to the center of the clock with top and left property. And we have gave round shape again to it.

Adding Hands to Clock Center

.hand1{
    position: relative;
    background-color: tomato;
    height: 55px;
    width: 6px;
    border-radius: 27px;
    bottom: 7px;
    left: 57px;
}
.hand2{
    position: relative;
    background-color: tomato;
    height: 6px;
    width: 35px;
    border-radius: 15px;
    left: 26px;
    bottom: 13px;
}

Now for hand1, we have added some height and width to it also, we have added background color tomato. Now we want these hands having some curve at the edge of them, so for that we have added border radius with some pixels. Also, we have adjusted it using bottom and left property.

Same as hand1, we have done styling for hand2. We have just modified the height, width, and border-radius. Also, we have adjusted left and bottom position as well.

Adding Animation to Hands

.hand1{
    position: relative;
    background-color: tomato;
    height: 55px;
    width: 6px;
    border-radius: 27px;
    bottom: 7px;
    left: 57px;
    animation: spin-a 2s infinite;
    transform-origin: bottom;
}
@keyframes spin-a{
    100%{
        transform: rotate(360deg);
    }
}
.hand2{
    position: relative;
    background-color: tomato;
    height: 6px;
    width: 35px;
    border-radius: 15px;
    left: 26px;
    bottom: 13px;
    animation: spin-b 3s infinite;
    transform-origin: right;
}
@keyframes spin-b{
    100%{
        transform: rotate(360deg);
    }
} 

To perform animation, we have add animation property which have name spin with 2s duration for infinity times. And also, we have added a transform-origin property, with this we can do animation with respect to it. Here we have gave bottom in hand1, so animation will perform assuming the bottom as center of the hand1.

For animation definition, we can use @keyframes for defining animation, here we have rotate hand1 for 360 degrees.

Same way, we have done for hand2 with some extra second of delay.

Full Source Code To Make Clock Loader Using CSS

index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Clock Loader</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <div class="clock">
            <div class="center"></div>
            <div class="hand1"></div>
            <div class="hand2"></div>
        </div>
    </body>

</html>

style.css

body{
    margin: 0;
    padding: 0;
    background-color: #ffff4d;
}

.clock{
    position: absolute;
    top: 43%;
    left: 43%;
    height: 120px;
    width: 120px;
    background-color: white;
    border-radius: 50%;
    border: 6px solid #5c5c8a;
}

.center{
    position: relative;
    background-color: tomato;
    height: 15px;
    width: 15px;
    border-radius: 50%;
    top: 52px;
    left: 52px;
}

.hand1{
    position: relative;
    background-color: tomato;
    height: 55px;
    width: 6px;
    border-radius: 27px;
    bottom: 7px;
    left: 57px;
    animation: spin-a 2s infinite;
    transform-origin: bottom;
}
@keyframes spin-a{
    100%{
        transform: rotate(360deg);
    }
}
.hand2{
    position: relative;
    background-color: tomato;
    height: 6px;
    width: 35px;
    border-radius: 15px;
    left: 26px;
    bottom: 13px;
    animation: spin-b 3s infinite;
    transform-origin: right;
}
@keyframes spin-b{
    100%{
        transform: rotate(360deg);
    }
} 

Output

Clock Loader Using CSS
Demo
Download Code

Check out video reference here:

You May Also Like:

  • How To Make Paint Loading Animation in CSS
  • How To Make Chemical Reaction With CSS Animation
  • How To Make Skeleton Loading Animation With CSS & JS

Related

Subscribe to Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

TAGGED: Animation, Clock Loader Using CSS, loader
Share this Article
Facebook Twitter Email Print
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Posted by Admin
Follow:
Rocoderes is a blog you can learn HTML, CSS, JavaScript, React Js and Python along with creative coding stuff and free source code files.
Previous Article Modern eCommerce Website with HTML How to Make a Modern eCommerce Website with HTML
Next Article Clock Loader Using CSS fidget spinner loader How to Make Fidget Spinner Loader Using CSS
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

- Advertisement -

You Might Also Like

Price Range Slider

How to Make Price Range Slider Using JavaScript

December 8, 2022
save text as File in HTML

How to Save Text as File in JavaScript

December 5, 2022
Calendar in HTML

How to Make Dynamic Calendar in HTML & JavaScript

December 5, 2022
instagram signup form

How to Make Instagram Signup Page In HTML and CSS

December 5, 2022
rocoderesrocoderes
Follow US

Copyright © 2022 All Right Reserved By Rocoderes

  • Home
  • About us
  • Contact us
  • Disclaimer
Join Us!

Subscribe to our newsletter and never miss our latest news, podcasts etc.

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?