From 36bb2054c65efaabfad011c7c5488b8177ce0067 Mon Sep 17 00:00:00 2001 From: AmrutaJayanti <142327526+AmrutaJayanti@users.noreply.github.com> Date: Sat, 8 Jun 2024 11:40:41 +0530 Subject: [PATCH 1/2] Create CSS-Animations.md --- docs/CSS/css-basics/CSS-Animations.md | 166 ++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 docs/CSS/css-basics/CSS-Animations.md diff --git a/docs/CSS/css-basics/CSS-Animations.md b/docs/CSS/css-basics/CSS-Animations.md new file mode 100644 index 000000000..92c0c451b --- /dev/null +++ b/docs/CSS/css-basics/CSS-Animations.md @@ -0,0 +1,166 @@ +--- +id: css-animations +title: CSS Animations +sidebar_label: CSS Animations +sidebar_position: 1 +tags: [html, introduction, web development, markup language, hyper text, web pages, career opportunities, personal growth, web-development, web design, web pages, websites, career opportunities, contribute to the web, stay relevant, express yourself, learn other technologies, have fun, how to use html, steps to start using html, set up your development environment, create your first html document, learn html syntax and structure, explore html elements and-attributes] +description: In this tutorial you will learn about animations in CSS +--- + +## 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 Rule +When you specify CSS styles inside the `@keyframes` rule, the animation will gradually change from the current style to the new style at certain times. +To get an animation to work, you must bind the animation to an element. + +```css +/* The animation code */ +@keyframes example { + from {background-color: red;} + to {background-color: yellow;} +} + +/* The element to apply the animation to */ +div { + width: 100px; + height: 100px; + background-color: red; + animation-name: example; + animation-duration: 4s; +} +``` + +
+ Hello World! +
+
+ +The `animation-duration` property defines how long an animation should take to complete. If the `animation-duration` property is not specified, no animation will occur, because the default value is 0s (0 seconds). +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. + +## Delay an Animation +The `animation-delay` property specifies a delay for the start of an animation. + +```css +div { + width: 100px; + height: 100px; + position: relative; + background-color: red; + animation-name: example; + animation-duration: 4s; + animation-delay: 2s; +} +``` + +
+ Hello World! +
+
+ +# Times animation should run +The `animation-iteration-count` property specifies the number of times an animation should run. + +```css +div { + width: 100px; + height: 100px; + position: relative; + background-color: red; + animation-name: example; + animation-duration: 4s; + animation-iteration-count: 3; +} +``` + + +
+ Hello World! +
+
+ +# Direction of the animation + +The `animation-direction` property specifies whether an animation should be played forwards, backwards or in alternate cycles. + +The `animation-direction` property can have the following values: + +- `normal` - The animation is played as normal (forwards). This is default +- `reverse` - The animation is played in reverse direction (backwards) +- `alternate` - The animation is played forwards first, then backwards +- `alternate-reverse` - The animation is played backwards first, then forwards + +```css +div { + width: 100px; + height: 100px; + position: relative; + background-color: red; + animation-name: example; + animation-duration: 4s; + animation-direction: reverse; +} +``` + + +
+ Hello World! +
+
+ + + + + From 5651e57f04526865ba1378ca6a90d038efa9267c Mon Sep 17 00:00:00 2001 From: AmrutaJayanti <142327526+AmrutaJayanti@users.noreply.github.com> Date: Sat, 8 Jun 2024 17:17:00 +0530 Subject: [PATCH 2/2] Update CSS-Animations.md --- docs/CSS/css-basics/CSS-Animations.md | 159 ++++++++++++++------------ 1 file changed, 89 insertions(+), 70 deletions(-) diff --git a/docs/CSS/css-basics/CSS-Animations.md b/docs/CSS/css-basics/CSS-Animations.md index 92c0c451b..3922f5bec 100644 --- a/docs/CSS/css-basics/CSS-Animations.md +++ b/docs/CSS/css-basics/CSS-Animations.md @@ -2,7 +2,6 @@ id: css-animations title: CSS Animations sidebar_label: CSS Animations -sidebar_position: 1 tags: [html, introduction, web development, markup language, hyper text, web pages, career opportunities, personal growth, web-development, web design, web pages, websites, career opportunities, contribute to the web, stay relevant, express yourself, learn other technologies, have fun, how to use html, steps to start using html, set up your development environment, create your first html document, learn html syntax and structure, explore html elements and-attributes] description: In this tutorial you will learn about animations in CSS --- @@ -14,7 +13,7 @@ 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 Rule +## The `@keyframes` Rule When you specify CSS styles inside the `@keyframes` rule, the animation will gradually change from the current style to the new style at certain times. To get an animation to work, you must bind the animation to an element. @@ -35,14 +34,22 @@ div { } ``` -
- Hello World! -
-
+
+ Hello World! +
+ + The `animation-duration` property defines how long an animation should take to complete. If the `animation-duration` property is not specified, no animation will occur, because the default value is 0s (0 seconds). 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)). @@ -62,25 +69,32 @@ div { animation-delay: 2s; } ``` - -
- Hello World! -
-
+ +
+ Hello World! +
+ +
# Times animation should run The `animation-iteration-count` property specifies the number of times an animation should run. @@ -97,25 +111,29 @@ div { } ``` - -
- Hello World! -
-
+ +
+ Hello World! +
+ +
# Direction of the animation @@ -139,28 +157,29 @@ div { animation-direction: reverse; } ``` - - -
- Hello World! -
-
- - + +
+ Hello World! +
+ +