How To Create Animated Preloader using HTML, CSS and JavaScript

Hello friends, today we will be going to Create Animated Preloader using HTML, CSS and JavaScript. I have posted many videos and articles before related to the JavaScript project, now this the something new that we are going to build.

Video Tutorial of How To Create Animated Preloader using HTML, CSS and JavaScript


As you have seen on the given video tutorial of  How To Create Animated Preloader using HTML, CSS and JavaScript, 

If you are feeling bored watching the given video tutorial of How To Create Animated Preloader using HTML, CSS and JavaScriptv then you can copy or download the given codes below:


How To Create Animated Preloader using HTML, CSS and JavaScript | Free Source Code

To create this program (Preloader). First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste the following codes in your file.

In the first place, make a HTML document with the name of index.html and glue the given codes in your HTML record. Keep in mind, you've to make a document with .html extension.
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Animated Circular Preloader</title>
	<link rel="stylesheet" href="./style.css">
	<!-- S-Tech04 -->
</head>
<body>
	<div class="box">
		<div class="circle" dots="100"></div>
		<span>LOADING</span>
	</div>

	<script src="./script.js"></script>
</body>
</html>
Second, make a CSS record with the name of style.css and glue the given codes in your CSS document. Keep in mind, you've to make a record with .css extension.
*
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
}
body
{
    display: flex;
    justify-content: center;
    align-items: center;
    background: #333;
    min-height: 100vh;
}
.box
{
    margin: 20px;
    position: relative;
}
.box span
{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    font-size: 28px;
    font-weight: 700;
    color: #52a8ff;
    letter-spacing: 2px;
    text-shadow: 0 0 10px #52a8ff;
}
.circle
{
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.circle .points
{
    width: 3px;
    height: 15px;
    background: #0007;
    position: absolute;
    border-radius: 3px;
    transform: rotate(calc(var(--i)*var(--rot))) translateY(-100px);
    animation: glow 0.5s linear infinite;
    animation-delay: calc(var(--i)*0.01s);

}
@keyframes glow
{
    0%
    {
        background: #0007;
        box-shadow: none;
    }
    50%
    {
        background: #52a8ff;
        box-shadow: 0 0 10px #52a8ff;
    }
    100%
    {
        background: #0007;
        box-shadow: none;
    }
}
last, create a JavaScript file with the name of script.js and paste the given codes in your JavaScript file. Remember, you’ve to create a file with .js extension.
const circles = document.querySelectorAll('.circle');
circles.forEach(elem=>{
    var dots = elem.getAttribute('dots');
    var points = '';
    var rotate = 360/dots;
    for (var i = 0; i < dots; i++) {
        points+= `<div class="points" style="--i: ${i}; --rot: ${rotate}deg;"></div>`
    };
    elem.innerHTML = points;
})
That’s all, now you’ve successfully created a program to Create Animated Preloader using HTML, CSS and JavaScript. If your code doesn’t work or you’ve faced any error/problem, please download the source code files from the given download button. It’s free and a .zip file will be downloaded then you’ve to extract it.
Click on the following download button to download all source code files.


Download Now
Please Wait...
Direct Link click here.

How can I help you

Post a Comment

How can I help you

Post a Comment (0)

Previous Post Next Post