Detailed explanation of the transition attribute of simple CSS animation

Detailed explanation of the transition attribute of simple CSS animation

1. Understanding of transition attributes

1. The transition attribute is a shorthand attribute that can be used to set four transition properties:

transition-property The name of the CSS property for the transition effect (height, width, opacity, etc.).
transition-duration The time it takes to complete the transition effect.
transition-timing-function specifies the speed curve of a speed effect.
transition-delay When does the transition effect start (delay time).

Note: If the transition-duration property is 0, no transition effect will occur.

2. The value of the gradient function:

The gradient function is the transition-timing-function;

The preset value of the Bezier curve

Ease gradually increases, uniform speed, slows down cubic-bezier (0.25, 0.1, 0.25, 1)
ease-in gradually faster, uniform speed cubic-bezier (0.42, 0, 1, 1)
ease-out uniform speed, slow down cubic-bezier (0,0,0.58,1)
ease-in-out is similar to ease, but has a larger acceleration (larger amplitude) than ease. cubic-bezier(0.42,0,0.58,1)
Linear uniform speed throughout cubic-bezier (0,0,1,1)

3. Abbreviation: transition: css attribute name transition time gradient function value delay time;

2. Simple animation example operation

1. Insert two pictures first

<div class="A">
        <img src="img/taking medicine.jpg" alt="">
        <img src="img/main_bg.jpg" alt="">
    </div>

2. Set the style for the picture

<style>
        .A {
            margin: auto 100px;
            height: 400px;
            width: 600px;
            position: relative;
        }
        .A img:nth-child(1) {
            height: 300px;
            width: 300px;
            position: absolute;
        }
        .A img:nth-child(2) {
            height: 300px;
            width: 300px;
            position: absolute;
            transition: opacity 3s ease-in 2s;
        }
        .A img:nth-child(2):hover {
            opacity: 0;
        }
        img {
            height: 300px;
            width: 300px;
        }
        </style>

3. The animation effect obtained is:

Summarize

The above is a detailed explanation of the transition attribute of simple CSS animation introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  How to modify the "Browse" button of the html form to upload files

>>:  How to quickly install nginx under Windows and configure it to start automatically

Recommend

Implementation of FIFO in Linux process communication

FIFO communication (first in first out) FIFO name...

3 codes for automatic refresh of web pages

In fact, it is very simple to achieve this effect,...

Sample code for implementing Google third-party login in Vue

Table of contents 1. Developer Platform Configura...

Implementation and optimization of MySql subquery IN

Table of contents Why is IN slow? Which is faster...

HTML (css style specification) must read

CSS style specifications 1. Class Selector 2. Tag...

Detailed explanation of display modes in CSS tags

Label display mode (important) div and span tags ...

Why should MySQL fields use NOT NULL?

I recently joined a new company and found some mi...

Solutions to the failure and invalidity of opening nginx.pid

Table of contents 1. Problem Description 2. Probl...

JavaScript gets the scroll bar position and slides the page to the anchor point

Preface This article records a problem I encounte...

Why should you be careful with Nginx's add_header directive?

Preface As we all know, the nginx configuration f...

Vue page monitoring user preview time function implementation code

A recent business involves such a requirement tha...

How are Vue components parsed and rendered?

Preface This article will explain how Vue compone...

Analysis of MySQL example DTID master-slave principle

Table of contents 1. Basic Concepts of GTID 2. GT...

Six-step example code for JDBC connection (connecting to MySQL)

Six steps of JDBC: 1. Register the driver 2. Get ...

MySQL data types full analysis

Data Type: The basic rules that define what data ...