Web Front-end
CSS Tutorial
CSS web page loading animation: create various cool loading animation effects
CSS web page loading animation: create various cool loading animation effects

When users enter a web page, the most impatient thing is waiting for the page to load. In order to alleviate users' anxiety, many websites have begun to use CSS loading animations to make page loading more interesting. In this article, we will learn how to use CSS to create various cool loading animation effects, and provide specific code examples to help you implement it.
1. Basic animation
First let us create some basic loading animations. We can use the animation property in CSS to create a basic animation. The animation property has several sub-properties, as follows:
- animation-name: Select the name of the keyframe rule to be applied.
- animation-duration: Defines the duration of a cycle (in seconds or milliseconds).
- animation-timing-function: Define a cycle speed curve.
- animation-delay: Define the delay time of a cycle.
- animation-iteration-count: Defines the number of times the animation should play.
Now, let’s look at a few different types of basic loading animations.
1. Rotation animation
In this loading animation, we use the following code to define a rotation keyframe:
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}The above code uses the @keyframes rule to define A keyframe named "rotate". In this keyframe, we use the transform attribute to define the rotation. In from and to, we define the degree of rotation, from 0 to 360 degrees.
Next, we need to specify this animation for our "loader" element:
.loader {
animation-name: rotate;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}2. Flash animation
In this loading animation, we use the following code to Define a cyclic blinking keyframe:
@keyframes blink {
50% {
opacity: 0.5;
}
}The above code uses the @keyframes rule to define a keyframe named "blink". In this keyframe, we use the opacity property to define the transparency of the element. At 50%, we set it to 0.5, which will make it cycle between two states.
To apply this animation to our "loader" element, use the following code:
.loader {
animation-name: blink;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}2. Advanced Animation
Now, we have learned how to Create a basic loading animation in , let's further explore how to create more advanced animations. Here are some cool loading animations and their code examples.
1. Wave animation
In this loading animation, we use the following code to define the key frame of a wave mode:
@keyframes wave {
0% {
transform: translateX(0) translateY(0);
}
50% {
transform: translateX(30px) translateY(15px);
}
100% {
transform: translateX(0) translateY(0);
}
}In the above code, we use transform Properties to create waveform effects. At 0% and 100% positions, we set the element to its initial position. At the 50% position, we use translateX (horizontal translation) and translateY (vertical translation) to create the waveform.
Next, we specify this animation for our "loader" element:
.loader {
animation-name: wave;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}2. Diffusion animation
In this loading animation, we use the following code to define A diffusion keyframe:
@keyframes spread {
0% {
transform: scale(0);
opacity: 0.5;
}
50% {
transform: scale(1);
opacity: 0.1;
}
100% {
transform: scale(0);
opacity: 0.5;
}
}In the above code, we use the transform attribute to create a diffusion effect. At 0% and 100% we set the element to its initial values of minimization and transparency. At the 50% position, we use the scale property to create the diffusion animation.
Next, we specify this animation for our "loader" element:
.loader {
animation-name: spread;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
}Summary
By using CSS, we can create various types of loading animations for our website . These loading animations can make page loading more interesting and relieve users' waiting anxiety. In this article, we learned how to create some basic loading animations, as well as how to make more advanced animations. I hope these code examples are helpful in your work.
The above is the detailed content of CSS web page loading animation: create various cool loading animation effects. For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
1384
52
Working With GraphQL Caching
Mar 19, 2025 am 09:36 AM
If you’ve recently started working with GraphQL, or reviewed its pros and cons, you’ve no doubt heard things like “GraphQL doesn’t support caching” or
Building an Ethereum app using Redwood.js and Fauna
Mar 28, 2025 am 09:18 AM
With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum
Vue 3
Apr 02, 2025 pm 06:32 PM
It's out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.
Creating Your Own Bragdoc With Eleventy
Mar 18, 2025 am 11:23 AM
No matter what stage you’re at as a developer, the tasks we complete—whether big or small—make a huge impact in our personal and professional growth.
Can you get valid CSS property values from the browser?
Apr 02, 2025 pm 06:17 PM
I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That's like this.
A bit on ci/cd
Apr 02, 2025 pm 06:21 PM
I'd say "website" fits better than "mobile app" but I like this framing from Max Lynch:
Comparing Browsers for Responsive Design
Apr 02, 2025 pm 06:25 PM
There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing
Stacked Cards with Sticky Positioning and a Dash of Sass
Apr 03, 2025 am 10:30 AM
The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.


