Pure HTML5+CSS3 to create image rotation

不言
Release: 2018-06-05 15:00:04
Original
1805 people have browsed it

This article mainly introduces pure HTML5 CSS3 production of image rotation. Some animation special effects achieved by HTML5 combined with CSS3 are relatively easy to implement. Interested friends can refer to it.

This example can be applied to It is very practical in many projects and I hope everyone can master it.

The effect diagram is as follows:

It is not difficult to achieve this effect. The code list is as follows:

XML/HTML CodeCopy content to the clipboard

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #liu{     
            width:280px;     
            height: 279px;     
            background: url(shishi.png) no-repeat;     
            border-radius:140px;     
            -webkit-animation:run 6s linear 0s infinite;     
        }     
        #liu:hover{     
            -webkit-animation-play-state:paused;     
        }     
        @-webkit-keyframes run{     
            from{     
                -webkit-transform:rotate(0deg);     
            }     
            to{     
                -webkit-transform:rotate(360deg);     
            }     
        }     
    </style>
</head>
<body>
    <p id="liu"></p>
</body>
</html>
Copy after login

1. The p with id liu is the area used to display pictures, but the pictures here are using background image, and achieve a circular effect by setting rounded corners.
2. The key part of the code is how to make the picture rotate infinitely. We can use -webkit-animation and @-webkit-keyframes in combination to accomplish this.

-webkit-animation is a composite attribute, defined as follows:

-webkit-animation: name duration timing-function delay iteration_count direction;

name: yes The method needs to be specified in @-webkit-keyframes to perform animation.

duration: The duration of animation execution in one cycle.

timing-function: The effect of animation execution can be linear, or it can be "fast in and slow out", etc.

delay: The duration of animation delay execution.

iteration_count: The number of times the animation loop is executed. If it is infinite, it will be executed infinitely.

direction: animation execution direction.

3. The two attributes from and to in @-webkit-keyframes specify the initial value and end value of animation execution.

4. -webkit-animation-play-state:paused; Pauses the execution of animation.

The above is the entire content of this article. I hope it will be helpful to everyone in achieving special effects of image rotation.

Related recommendations:

html5 example code for generating histogram (bar chart) effect

The above is the detailed content of Pure HTML5+CSS3 to create image rotation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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!