How to achieve a rotating animation effect in css

WBOY
Release: 2021-12-09 15:08:45
Original
22641 people have browsed it

Method: 1. Use the "element {animation: name time infinite}" statement to bind animation to the element; 2. Use the "@keyframes name {100%{transform:rotate(rotation angle)}}" statement Set the rotation action of animation to achieve the effect of constant rotation of elements.

How to achieve a rotating animation effect in css

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

How to achieve a rotating animation effect in css

In css, you can use the animation attribute to bind animation to an element, and the animation attribute can be controlled The animation duration and times, the syntax is:

animation: name duration timing-function delay iteration-count direction;
Copy after login

where:

How to achieve a rotating animation effect in css

When the value of the attribute is set to "infinite", it specifies that the animation can be played infinitely. When we bind a rotation animation to an element, it can keep rotating.

Then set the rotation action of the animation through @keyframes rules.

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;
            background-color:pink;
            animation:fadenum 5s infinite;
        }
        @keyframes fadenum{
   100%{transform:rotate(360deg);}
}
    </style>
</head>
<body>
    <div></div>
</body>
</html>
Copy after login

Output result:

How to achieve a rotating animation effect in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to achieve a rotating animation effect in css. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!