This time I will bring you the method of directly implementing the carousel using the animation attribute. What are the precautions for implementing the carousel using the animation attribute? The following is a practical case, let’s take a look at it.
Introduction to animation:
The animation property of CSS3 can be used to control each step of the animation by controlling key frames just like Flash animation. More complex animation effects. 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 attributeSyntax: animation: name duration timing-function delay iteration-countdirection;
The six animation attributes set by animation:
animation-name: stipulates that it needs to be bound The keyframe name assigned to the selector. 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>
Picture tags should be placed on the same line, otherwise there will be gaps between the pictures.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website! Recommended reading:
Detailed explanation of the use of pointer-events in css3
Detailed explanation of the use of focus-within
The above is the detailed content of The animation attribute directly implements the carousel method. For more information, please follow other related articles on the PHP Chinese website!