1. What isCSS Animations is a proposed module for Cascading Style Sheets that allows Extensible Markup Language (XML) elements to be animated using CSS. It refers to the process of elements gradually transitioning from one style to another. There are many common animation effects, such as translation, rotation, scaling, etc. Complex animation is a combination of multiple simple animations. There are several ways to implement animation with CSS:
2. Implementation transition implements gradient animationThe properties of transition are as follows:
The values of timing-function are as follows:
Note: Not all properties can be used in transitions, such as display:none<->display:block For example, to achieve the animation effect of changing when the mouse moves <style> .base { width: 100px; height: 100px; display: inline-block; background-color: #0EA9FF; border-width: 5px; border-style: solid; border-color: #5daf34; transition-property: width, height, background-color, border-width; transition-duration: 2s; transition-timing-function: ease-in; transition-delay: 500ms; } /*Abbreviation*/ /*transition: all 2s ease-in 500ms;*/ .base:hover { width: 200px; height: 200px; background-color: #5daf34; border-width: 10px; border-color: #3a8ee6; } </style> <div ></div> transform animationContains four commonly used functions:
Generally used with transition overuse Note that transform does not support inline elements, so convert it to block before using it. For example <style> .base { width: 100px; height: 100px; display: inline-block; background-color: #0EA9FF; border-width: 5px; border-style: solid; border-color: #5daf34; transition-property: width, height, background-color, border-width; transition-duration: 2s; transition-timing-function: ease-in; transition-delay: 500ms; } .base2 { transform: none; transition-property: transform; transition-delay: 5ms; } .base2:hover { transform: scale(0.8, 1.5) rotate(35deg) skew(5deg) translate(15px, 25px); } </style> <div ></div> You can see that the box has been rotated, tilted, translated, and enlarged. animation implements custom animationAnimation is an abbreviation of 8 properties, as follows:
CSS animation only needs to define some key frames, and the browser will calculate the rest of the frames based on the interpolation of the timing function. Define keyframes via @keyframes Therefore, if we want the element to rotate in a circle, we only need to define the start and end frames: @keyframes rotate{ from{ transform: rotate(0deg); } to{ transform: rotate(360deg); } } From means the first frame, and to means the last frame. You can also use percentages to describe the life cycle @keyframes rotate{ 0%{ transform: rotate(0deg); } 50%{ transform: rotate(180deg); } 100%{ transform: rotate(360deg); } } After defining the keyframe, you can use it directly: animation: rotate 2s; Conclusion
The above is the detailed content of the implementation methods of common CSS3 animations. For more information on the implementation of CSS3 animations, please pay attention to other related articles on 123WORDPRESS.COM! |
<<: Detailed explanation of jQuery's core functions and event handling
>>: HTML+CSS+JS sample code to imitate the brightness adjustment effect of win10
centos7 switch boot kernel Note: If necessary, it...
<br /> Focusing on the three aspects of text...
This article describes the deployment method of A...
Install MySQL for the first time on your machine....
Only show the top border <table frame=above>...
Table of contents 1. Resources and Construction 1...
1. Vulnerability Description On May 15, 2019, Mic...
Since I often install the system, I have to reins...
<br />Related articles: innerHTML HTML DOM i...
Before starting the main text, I will introduce s...
Core code /*-------------------------------- Find...
Today I was dealing with the issue of migrating a...
The json data must be returned in html format That...
I mainly introduce how to develop a lucky wheel g...
1. Docker imports local images Sometimes we copy ...