Detailed explanation of how to use CSS3 animation animation properties to achieve carousel effects

巴扎黑
Release: 2018-05-18 10:57:48
Original
4356 people have browsed it

The animation attribute of CSS3 can be used to control each step of the animation by controlling key frames just like Flash animation, achieving more complex animation effects. Through this article, I will share with you the carousel effect based on CSS3 animation animation properties. Friends who need it can refer to it

animation introduction:

The animation attribute of CSS3 can control each step of the animation by controlling key frames to achieve more complex animation effects just like Flash animation. The animation effect achieved by ainimation mainly consists of two parts:

1) Declare an animation through frames similar to those in Flash animation;

2) Call the animation declared by key frames in the animation attribute.

animation attribute value:

animation attribute is a shorthand attribute

Syntax: animation: name duration timing-function delay iteration-count direction;

Six animation attributes set by animation:

animation-name: specifies the keyframe that needs to be bound to the selector name. Values:

none: (Default) Specifies no animation effect (can be used to override animations from the cascade).

keyframename: Specifies the name of the keyframe that needs to be bound to the selector.

animation-duration: Specifies the time it takes to complete the animation, in seconds or milliseconds. Value:

time: Specifies the time it takes to complete the animation. The default value is 0, which means no animation effect.

animation-timing-function: Specifies the speed curve of animation. Value:

ease: Default. The animation starts at a slow speed, then speeds up, then slows down before ending.

linear: The speed of the animation is the same from beginning to end.

ease-in: The animation starts at a low speed.

ease-out: The animation ends at a low speed.

ease-in-out: The animation starts and ends at a slow speed.

cubic-bezier(n,n,n,n): Define your own values ​​in the cubic-bezier function. Possible values ​​are numeric values ​​from 0 to 1.

animation-delay: Specifies the delay before the animation starts. Values:

time: (optional) Defines the time to wait before starting the animation, in seconds or milliseconds. The default value is 0.

animation-iteration-count: Specifies the number of times the animation should be played. Value:

n: The value that defines the number of animation playback times.

infinite: Specifies that the animation should be played infinitely.

animation-direction: Specifies whether the animation should be played in reverse in turn. Value:

normal: default value. The animation should play normally.

alternate: The animation should be played in reverse in turn.

animation animation implementation carousel chart

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图片轮换</title>
    <style type="text/css">
        p,img{
            margin: 0;
            padding: 0;
        }
        .p_first{
            width: 1000px;
            height: 300px;
            margin-top: 100px;
            margin-left: 250px;
            overflow: hidden;
        }
        .p_second{
            width: 4000px;
            position: relative;
            animation: myimg 12s linear infinite normal; 
        }
        @keyframes myimg{
            0{
                left: 0;
            }
            5%{
                left: 0;
            }
            30%{
                left: -1000px;
            }
            35%{
                left: -1000px;
            }
            60%{
                left: -2000px;
            }
            65%{
                left: -2000px;
            }
            95%{
                left: -3000px;
            }
            100%{
                left: -3000px;
            }
        }
    </style>
</head>
<body>
    <p class="p_first">
        <p class="p_second">
            <img src="images/011-1.jpg" alt=""><img src="images/011-2.jpg" alt=""><img src="images/011-3.jpg" alt=""><img src="images/011-1.jpg" alt="">
        </p>
    </p>
</body>
</html>
Copy after login

Picture tags should be placed on the same line, otherwise there will be gaps between the pictures.

The above is the detailed content of Detailed explanation of how to use CSS3 animation animation properties to achieve carousel effects. 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