Hello readers, Today in this blog you’ll learn how to create an Animated Gradient Shiny Loader or Preloader in HTML CSS & JavaScript. Earlier I have shared a Color Changing Shiny Loader using HTML & CSS only Now it’s time to create an Animated Gradient Loader with Percentage in JavaScript.
Preloaders are what you inspect on the screen while the rest of the page’s content is still loading. Preloaders or loaders are often easy or complex animations that are used to keep visitors entertained while server operations finish processing.
At first, this loader is in the initial stage, where there is a loader and 0% text or number at the center on the webpage. But when you click on that center text or number, the loader will be activated and it starts to rotates as well as the center percentage also starts to increase from 0% to 100%. When it completed 100%, the loader stops rotating.
If you’re feeling difficult to understand what I am saying. You can watch a full video tutorial on this program (Animated Gradient Shiny Loader).
Video Tutorial of Gradient Preloader in JavaScript
If you’re a beginner you can create this type of loader or preloader for learning purposes. But if you know JavaScript you can use this loader in your websites, projects, anywhere you want.
If you like this program (Animated Gradient Shiny Loader) and want to get source codes. You can easily get the source codes of this program. To get the source codes you just need to scroll down.
<!DOCTYPE html> <!-- Created By CodingNepal --> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Gradient Ring or Loader</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="outer"></div> <div class="inner"> <span>0%</span> </div> <!-- This is Javascript Code --> <script> let outer = document.querySelector(".outer"); let inner = document.querySelector(".inner"); let percent = document.querySelector("span"); let count = 0; inner.addEventListener('click', function(){ let loading = setInterval(function(){ if(count == 100){ outer.classList.remove("active-loader"); outer.classList.add("active-loader-2"); clearInterval(); }else{ count = count + 1; percent.textContent = count + '%'; outer.classList.add("active-loader"); } },200); }); </script> </body> </html>
Second, create a CSS file with the name of style.css and paste the given codes in your CSS file. Remember, you’ve to create a file with .css extension.
html,body{ display: flex; align-items: center; justify-content: center; height: 100vh; font-family: sans-serif; background: #240f52; overflow: hidden; } .outer{ height: 300px; width: 300px; background: linear-gradient(135deg,#FEED07 0%,#FE6A50 5%,#ED00AA 15%,#2FE3FE 50%,#8900FF 100%); border-radius: 50%; } .inner{ position: absolute; width: 275px; height: 275px; text-align: center; line-height: 275px; background: #240f52; border-radius: 50%; cursor: default; /* opacity: 0; */ } .inner span{ font-size: 60px; font-weight: 800; background: linear-gradient(135deg,#FEED07 0%,#FE6A50 5%,#ED00AA 15%,#2FE3FE 50%,#8900FF 100%); color: transparent; -webkit-background-clip: text; background-size: 300%; } .outer.active-loader{ animation: rotate 2s ease infinite; } @keyframes rotate { to{ transform: rotate(360deg); } } .outer.active-loader-2{ animation: rotate2 3s ease; } @keyframes rotate2 { to{ transform: rotate(360deg); } }
That’s all, now you’ve successfully created Animated Gradient Shiny Loader with HTML CSS & JavaScript. If your code does not work or you’ve faced any error/problem then please comment down or contact us from the contact page.
you are my mentor bro
you are multi talented
Thank you so much
Here is the code – https://drive.google.com/file/d/1Cmkayz63yzamVFZlnlLQemyj9BNi8wZ4/view?usp=sharing
I have tried can u give me a new code pls
Try it then send me the code pls pls pls pls pls sir I am ur big fan …
It's work bro..Please check your codes again
Not working bro