Hướng dẫn after trong css w3schools
ExampleInsert some text after the content of each element: Show
p::after { Try it Yourself » More "Try it Yourself" examples below. Definition and UsageThe Use the content property to specify the content to insert. Use the ::before selector to insert something before the content.
Browser SupportThe numbers in the table specifies the first browser version that fully supports the selector.
CSS Syntax ::after { More ExamplesExampleInsert content after every element, and style the inserted content: p::after { Try it Yourself » Related PagesCSS tutorial: CSS Pseudo-elements CSS Selector Reference: CSS ::before selector CSS AnimationsCSS allows animation of HTML elements without using JavaScript or Flash! CSS In this chapter you will learn about the following properties:
Browser Support for AnimationsThe numbers in the table specify the first browser version that fully supports the property.
What are CSS Animations?An animation lets an element gradually change from one style to another. You can change as many CSS properties you want, as many times as you want. To use CSS animation, you must first specify some keyframes for the animation. Keyframes hold what styles the element will have at certain times. The @keyframes RuleWhen you specify CSS styles inside the To get an animation to work, you must bind the animation to an element. The following example binds the "example" animation to the element. The animation will last for 4 seconds, and it will gradually change the background-color of the element from "red" to "yellow": Example /* The animation code */ /* The element to apply the animation to */ Try it Yourself » Note: The In the example above we have specified when the style will change by using the keywords "from" and "to" (which represents 0% (start) and 100% (complete)). It is also possible to use percent. By using percent, you can add as many style changes as you like. The following example will change the background-color of the element when the animation is 25%
complete, 50% complete, and again when the animation is 100% complete: Example /* The animation code */ /* The element to apply the animation to */ Try it Yourself » The following example will change both the background-color and the position of the element when the animation is 25% complete, 50% complete, and again when the animation is 100% complete: Example /* The animation code
*/ /* The element to apply the animation to */ Try it Yourself » Delay an AnimationThe The following example has a 2 seconds delay before starting the animation: Example div
{ Try it Yourself » Negative values are also allowed. If using negative values, the animation will start as if it had already been playing for N seconds. In the following example, the animation will start as if it had already been playing for 2 seconds: Example div { Try it Yourself » Set How Many Times an Animation Should RunThe The following example will run the animation 3 times before it stops: Example div { Try it Yourself » The following example uses the value "infinite" to make the animation continue for ever: Example div { Try it Yourself » Run Animation in Reverse Direction or Alternate CyclesThe The animation-direction property can have the following values:
The following example will run the animation in reverse direction (backwards): Example div { Try it Yourself » The following example uses the value "alternate" to make the animation run forwards first, then backwards: Example div { Try it Yourself » The following example uses the value "alternate-reverse" to make the animation run backwards first, then forwards: Example div { Try it Yourself » Specify the Speed Curve of the AnimationThe The animation-timing-function property can have the following values:
The following example shows some of the different speed curves that can be used: Example #div1 {animation-timing-function: linear;} Try it Yourself » Specify the fill-mode For an AnimationCSS animations do not affect an element before the first keyframe is played or after the last keyframe is played. The animation-fill-mode property can override this behavior. The The animation-fill-mode property can have the following values:
The following example lets the element retain the style values from the last keyframe when the animation ends: Example div { Try it Yourself » The following example lets the element get the style values set by the first keyframe before the animation starts (during the animation-delay period): Example div { Try it Yourself » The following example lets the element get the style values set by the first keyframe before the animation starts, and retain the style values from the last keyframe when
the animation ends:
Example div { Try it Yourself » Animation Shorthand PropertyThe example below uses six of the animation properties: Example div { Try it Yourself » The same animation effect as above
can be achieved by using the shorthand Example div { Try it Yourself » CSS Animation PropertiesThe following table lists the @keyframes rule and all the CSS animation properties:
|