Home > Web Front-end > CSS Tutorial > How to achieve left and right stretching animation effect in css3

How to achieve left and right stretching animation effect in css3

WBOY
Release: 2021-12-14 17:57:30
Original
3865 people have browsed it

Method: 1. Use the "element {animation: name time}" statement to bind animation to the element; 2. Use "@keyframes name {50%{transform:scale(left and right scaling multiple, 1);} }" statement, set the animation action of the element's expansion and contraction, and achieve the left and right expansion and contraction animation effect of the element.

How to achieve left and right stretching animation effect in css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to achieve the left and right scaling animation effect in css3

In css, if you want to achieve the left and right scaling animation, you need to bind the image element through the animation attribute. Set the animation and specify the animation time.

The keyframes rules are then used to specify the action of element animation. The specific action is based on the transform attribute and the scale function to scale the element.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            width:100px;
            height:100px;
            margin:0 auto;
            background-color:pink;
            animation:fadenum 5s;
        }
        @keyframes fadenum{
   50%{transform:scale(3,1);}
}
    </style>
</head>
<body>
    <div></div>
</body>
</html>
Copy after login

Output result:

How to achieve left and right stretching animation effect in css3

(Learning video sharing: css video tutorial)

The above is the detailed content of How to achieve left and right stretching animation effect in css3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template