亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
1. Scale Animation
2. Fade In
3. Spin Animation
4. Shake Animation prompt
5. Slide In from Top
6. Typewriter Effect
7. Pulse Animation
A brief description of commonly used animation properties:
Home Web Front-end CSS Tutorial css animation examples

css animation examples

Jul 28, 2025 am 03:31 AM
Example css animation

The hover button is enlarged to achieve interactive effects through transform: scale() and transition; 2. Fade in animation using @keyframes fadeIn with animation: forwards to maintain the final state; 3. Infinite rotation icon uses transform: rotate() and border differences to create loading effects; 4. Left and left jitter prompts move between 25% and 75% keyframes through translateX to generate warning feedback; 5. Slide up and down banners from negative values to 0 to slide into vision; 6. Text typewriter effect simulates verbatim input through width gradient and steps() and adds cursor flashing; 7. Pulse aperture uses scale and opacity to achieve breathing highlighting prompts; all animations should focus on performance optimization to avoid excessive use interfering with user experience, and the final effect should be natural and smooth and serve functions.

css animation examples

CSS animation is an important means to improve user experience in web design. Through @keyframes and animation attributes, we can achieve various smooth and natural visual effects. Below are some practical and common CSS animation examples for reference by beginners and advanced developers.

css animation examples

1. Scale Animation

Commonly used for buttons or icons, slightly enlargement when hovering, increasing the sense of interaction.

 .btn {
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  transition: transform 0.3s ease;
}

.btn:hover {
  transform: scale(1.1);
}

Use transform: scale() and transition to achieve smooth zooming, which is more efficient than directly changing width/height .

css animation examples

2. Fade In

A gradual effect from transparent to opaque when a page is loaded or an element appears.

 @keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 1s ease-in forwards;
}

forwards means that the animation is maintained at the last frame state after the end to prevent flashbacks.

css animation examples

3. Spin Animation

Suitable for loading icons or rotating logos.

 @keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

This is a classic "loading circle" effect that uses the color difference of the border to create a sense of rotation.


4. Shake Animation prompt

Used for form error prompts or button click feedback.

 @keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.5s ease-in-out;
}

Suitable for short and eye-catching feedback animations, do not overuse them to avoid disturbing users.


5. Slide In from Top

Commonly found in the notification bar or the top prompt bar.

 @keyframes slideInTop {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.banner {
  background: #ff6b6b;
  color: white;
  padding: 15px;
  text-align: center;
  animation: slideInTop 0.6s ease-out;
}

The animation slides in from the top of the screen, and the automatic hiding effect is better with timing.


6. Typewriter Effect

Simulates the animation of text input verbatim.

 .typewriter {
  overflow: hidden;
  border-right: 2px solid black;
  white-space: nowrap;
  margin: 0 auto;
  letter-spacing: 0.1em;
  animation: 
    typing 3.5s steps(30, end) forwards,
    blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: black }
}

Note: This effect requires that the element is block or inline-block and set fixed width or parent container limits.


7. Pulse Animation

Commonly used for focus prompts or new feature guidance.

 @keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 1;
  }
  70% {
    transform: scale(1.05);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.95);
    opacity: 1;
  }
}

.pulse {
  animation: pulse 1.5s infinite ease-in-out;
}

Can be used to highlight the Click here or New Message icon.


A brief description of commonly used animation properties:

property illustrate
animation-name Specify the @keyframes name
animation-duration Animation duration (such as 1s)
animation-timing-function Ease, linear, ease-in-out
animation-delay Delay start time
animation-iteration-count Number of times (infinite means infinite)
animation-direction Direction (normal, reverse, alternate)
animation-fill-mode Outside the animation state (forwards, backwards)
animation-play-state Control playback/pause (running, paused)

Basically, these common and practical animation examples. You can copy these codes into the project and use them directly, and then fine-tune the time, color, or size according to the design. The key is to keep the animation natural and not interfere with user operations .

Small suggestions: Consider using will-change or transform for complex animations to improve performance, avoid frequent re-arrangement and redrawing.

The above is the detailed content of css animation examples. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Introduction to Python functions: Usage and examples of isinstance function Introduction to Python functions: Usage and examples of isinstance function Nov 04, 2023 pm 03:15 PM

Introduction to Python functions: Usage and examples of the isinstance function Python is a powerful programming language that provides many built-in functions to make programming more convenient and efficient. One of the very useful built-in functions is the isinstance() function. This article will introduce the usage and examples of the isinstance function and provide specific code examples. The isinstance() function is used to determine whether an object is an instance of a specified class or type. The syntax of this function is as follows

Oracle DECODE function detailed explanation and usage examples Oracle DECODE function detailed explanation and usage examples Mar 08, 2024 pm 03:51 PM

The DECODE function in Oracle is a conditional expression that is often used to return different results based on different conditions in query statements. This article will introduce the syntax, usage and sample code of the DECODE function in detail. 1. DECODE function syntax DECODE(expr,search1,result1[,search2,result2,...,default]) expr: the expression or field to be compared. search1,

Go language indentation specifications and examples Go language indentation specifications and examples Mar 22, 2024 pm 09:33 PM

Indentation specifications and examples of Go language Go language is a programming language developed by Google. It is known for its concise and clear syntax, in which indentation specifications play a crucial role in the readability and beauty of the code. effect. This article will introduce the indentation specifications of the Go language and explain in detail through specific code examples. Indentation specifications In the Go language, tabs are used for indentation instead of spaces. Each level of indentation is one tab, usually set to a width of 4 spaces. Such specifications unify the coding style and enable teams to work together to compile

Introduction to Python functions: functions and examples of eval function Introduction to Python functions: functions and examples of eval function Nov 04, 2023 pm 12:24 PM

Introduction to Python functions: functions and examples of the eval function In Python programming, the eval function is a very useful function. The eval function can execute a string as program code, and its function is very powerful. In this article, we will introduce the detailed functions of the eval function, as well as some usage examples. 1. Function of eval function The function of eval function is very simple. It can execute a string as Python code. This means that we can convert a string

Introduction to Python functions: functions and examples of filter functions Introduction to Python functions: functions and examples of filter functions Nov 04, 2023 am 10:13 AM

Introduction to Python functions: The role and examples of the filter function Python is a powerful programming language that provides many built-in functions, one of which is the filter function. The filter function is used to filter the elements in the list and return a new list composed of elements that meet the specified conditions. In this article, we will introduce what the filter function does and provide some examples to help readers understand its usage and potential. The syntax of the filter function is as follows: filter(function

Application and example analysis of PHP dot operator Application and example analysis of PHP dot operator Mar 28, 2024 pm 12:06 PM

Application and example analysis of PHP dot operator In PHP, the dot operator (".") is an operator used to connect two strings. It is very commonly used and very flexible when concatenating strings. By using the dot operator, we can easily concatenate multiple strings to form a new string. The following will introduce the use of PHP dot operators through example analysis. 1. Basic usage First, let’s look at a basic usage example. Suppose there are two variables $str1 and $str2, which store two words respectively.

Introduction to Python functions: introduction and examples of range function Introduction to Python functions: introduction and examples of range function Nov 04, 2023 am 10:10 AM

Introduction to Python functions: Introduction and examples of range functions Python is a high-level programming language widely used in various fields. It is easy to learn and has a rich built-in function library. Among them, the range function is one of the commonly used built-in functions in Python. This article will introduce the function and usage of the range function in detail, and demonstrate its specific application through examples. The range function is a function used to generate an integer sequence. It accepts three parameters, which are the starting value (

Introduction to Python functions: usage and examples of getattr function Introduction to Python functions: usage and examples of getattr function Nov 04, 2023 pm 01:39 PM

Introduction to Python functions: Usage and examples of getattr function In Python, getattr() is a built-in function used to obtain the attribute value of an object. Without knowing the object's attribute name, you can use the getattr() function to dynamically access the attribute. This article will introduce the syntax, usage and examples of the getattr() function. The syntax of the getattr() function is as follows: getattr(object,name[,default]) parameters

See all articles