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

Detailed explanation of Linux CPU load and CPU utilization

CPU Load and CPU Utilization Both of these can re...

How to uninstall Linux's native openjdk and install sun jdk

See: https://www.jb51.net/article/112612.htm Chec...

How to use MySQL limit and solve the problem of large paging

Preface In daily development, when we use MySQL t...

MySQL multi-instance configuration solution

1.1 What is MySQL multi-instance? Simply put, MyS...

Detailed explanation of the use of state in React's three major attributes

Table of contents Class Component Functional Comp...

How to set up PostgreSQL startup on Ubuntu 16.04

Since PostgreSQL is compiled and installed, you n...

Detailed explanation of CSS label mode display property

The code looks like this: <!DOCTYPE html> &...

Use pure CSS to achieve switch effect

First is the idea We use the <input type="...

A brief discussion on value transfer between Vue components (including Vuex)

Table of contents From father to son: Son to Fath...

mysql wildcard (sql advanced filtering)

Table of contents First, let's briefly introd...

How to clear the cache after using keep-alive in vue

What is keepalive? In normal development, some co...

Why not use UTF-8 encoding in MySQL?

MySQL UTF-8 encoding MySQL has supported UTF-8 si...