How to Create CSS Loading Animation
HTML & CSS
Video Tutorial of CSS Loading Animation
CSS Loading Animation [Source Codes]
To Create CSS Loading Animation with HTML and CSS, follow the given steps line by line:
Create a folder. You can name this folder whatever you want, and inside this folder, create the mentioned files.
Create an index.html file. The file name must be index and its extension .html
Create a style.css file. The file name must be style and its extension .css
Once you create these files, paste the given codes into the specified files. If you don’t want to do these then scroll down and download the source code by clicking download button.
First, paste the following codes into your index.html file
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>CSS Loading Animation</title>
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <div></div>
- </body>
- </html>
Now paste the following codes into your style.css file
- body{
- background-color: #282A35;
- padding: 0;
- margin: 0;
- }
- div{
- height: 80px;
- width: 80px;
- background-color: #ffffff;
- position: absolute;
- margin: auto;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- border-radius: 50%;
- box-shadow: 0 0 0 -7px #ffffff,
- 0 0 0 -7px #ffffff,
- 0 0 0 -15px #ffffff,
- 0 0 0 -15px #ffffff;
- animation: split 2.4s forwards infinite;
- }
- @keyframes split{
- 25%{
- box-shadow: 90px 0 0 -7px #ffffff,
- -90px 0 0 -7px #ffffff,
- 90px 0 0 -15px #ffffff,
- -90px 0 0 -15px #ffffff;
- }
- 50%{
- box-shadow: 90px 0 0 -7px #ffffff,
- -90px 0 0 -7px #ffffff,
- 180px 0 0 -15px #ffffff,
- -180px 0 0 -15px #ffffff;
- }
- 75%{
- box-shadow: 90px 0 0 -7px #ffffff,
- -90px 0 0 -7px #ffffff,
- 90px 0 0 -15px #ffffff,
- -90px 0 0 -15px #ffffff;
- }
- 100%{
- box-shadow: 0 0 0 -7px #ffffff,
- 0 0 0 -7px #ffffff,
- 0 0 0 -15px #ffffff,
- 0 0 0 -15px #ffffff;
- }
- }
If you face any difficulties while creating your CSS Loading Animation or your code is not working as expected, you can download the source code files by clicking on the download button.