|
| 1 | +/** ------------------------------------- --> |
| 2 | +/** NOTES + TIPS |
| 3 | +/** ---------------------------------------- --> */ |
| 4 | + |
| 5 | +/*? animation-name: This property specifies the name of the keyframe animation you want to apply to an element. |
| 6 | +Example: animation-name: myAnimation; */ |
| 7 | + |
| 8 | +/*? animation-duration: Sets the duration of the animation in seconds (s) or milliseconds (ms). |
| 9 | +Example: animation-duration: 2s; */ |
| 10 | + |
| 11 | +/*? animation-timing-function: Defines the timing function that determines the acceleration and deceleration of the animation. |
| 12 | +Common values include ease, linear, ease-in, ease-out, ease-in-out, and more. |
| 13 | +Example: animation-timing-function: ease-in-out; */ |
| 14 | + |
| 15 | +/*? animation-delay: Specifies a delay before the animation starts. It can be in seconds (s) or milliseconds (ms). |
| 16 | +Example: animation-delay: 1s; */ |
| 17 | + |
| 18 | +/*? animation-iteration-count: Sets the number of times the animation should repeat. You can use values like infinite, 3, or 2n (for even iterations). |
| 19 | +Example: animation-iteration-count: infinite; */ |
| 20 | + |
| 21 | +/*? animation-direction: Determines whether the animation runs forwards, backward, or alternates between forward and backward cycles. |
| 22 | +Values include normal, reverse, alternate, and alternate-reverse. |
| 23 | +Example: animation-direction: alternate; */ |
| 24 | + |
| 25 | +/* very Important */ |
| 26 | + |
| 27 | +/*? @keyframes: |
| 28 | +This is not a property but a rule used to define the animation's keyframes. Keyframes specify how the element should look at various points during the animation. */ |
| 29 | + |
| 30 | +* { |
| 31 | + margin: 0; |
| 32 | + padding: 0; |
| 33 | + box-sizing: border-box; |
| 34 | + font-family: "Jost"; |
| 35 | +} |
| 36 | + |
| 37 | +body { |
| 38 | + background-color: #2b3033; |
| 39 | +} |
| 40 | + |
| 41 | +.container { |
| 42 | + width: 100vw; |
| 43 | + height: 100vh; |
| 44 | +} |
| 45 | + |
| 46 | +h1 { |
| 47 | + padding: 50px; |
| 48 | + color: #fff; |
| 49 | + font-size: 48px; |
| 50 | +} |
| 51 | + |
| 52 | +.box { |
| 53 | + width: 100px; |
| 54 | + height: 100px; |
| 55 | + background-color: #4861ec; |
| 56 | + box-shadow: 0 0 0px 15px #353f6d; |
| 57 | + margin: 50px; |
| 58 | + display: inline-block; |
| 59 | + border-radius: 50%; |
| 60 | + /*? animation start here */ |
| 61 | + animation-name: trip; |
| 62 | + animation-duration: 2.5s; |
| 63 | + animation-timing-function: linear; |
| 64 | + /* animation-delay: 2s; */ |
| 65 | + animation-iteration-count: 2; |
| 66 | + animation-direction: alternate; |
| 67 | + /* animation-fill-mode: backwards; */ |
| 68 | +} |
| 69 | + |
| 70 | +/* @keyframes lefttoright { |
| 71 | + from { |
| 72 | + translate: 0%; |
| 73 | + } |
| 74 | + to { */ |
| 75 | +/* translate: 90vw; */ |
| 76 | +/* translate: calc(90vw - 100px); |
| 77 | + } |
| 78 | +} */ |
| 79 | + |
| 80 | +/* @keyframes lefttoright { |
| 81 | + 0% { |
| 82 | + translate: 0%; |
| 83 | + } |
| 84 | + 50% { |
| 85 | + translate: 50vw 50vh; |
| 86 | + } |
| 87 | + 100% { |
| 88 | + translate: calc(90vw - 100px); |
| 89 | + } |
| 90 | +} */ |
| 91 | + |
| 92 | +@keyframes trip { |
| 93 | + 0% { |
| 94 | + background-color: #ffbb5cb5; |
| 95 | + transform: translate(200px, 0%); |
| 96 | + } |
| 97 | + 25% { |
| 98 | + background-color: #fcbf49; |
| 99 | + transform: translate(calc(90vw - 10%)); |
| 100 | + } |
| 101 | + 50% { |
| 102 | + background-color: #000000; |
| 103 | + transform: translate(calc(90vw - 10%), 500px); |
| 104 | + } |
| 105 | + 75% { |
| 106 | + background-color: #fcbf49; |
| 107 | + transform: translate(20%, 500px); |
| 108 | + } |
| 109 | + 100% { |
| 110 | + background-color: #ffbb5cb5; |
| 111 | + transform: translate(20%, 0%); |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +/** ------------------------------------- --> |
| 116 | +/** INTERVIEW QUESTIONS |
| 117 | +/** ---------------------------------------- --> */ |
| 118 | + |
| 119 | +/*? 1: In CSS animations, is it necessary to use the :hover or pseudo-class to trigger animations, or can animations be applied to elements on page load without user interaction? */ |
| 120 | +/* No need to use hover or anything. */ |
| 121 | + |
| 122 | +/*? 2: Explain the @keyframes rule in CSS animations. |
| 123 | +The @keyframes rule is used to define the animation sequence by specifying styles at various points during the animation's duration. */ |
| 124 | + |
| 125 | +/*? 3: What is the purpose of the animation-fill-mode property? |
| 126 | +animation-fill-mode determines how styles are applied to elements before and after the animation. Options include none, forwards, backwards, and both. */ |
| 127 | + |
| 128 | +/*? 4:How do you create an animation that reverses its direction when it reaches the end using CSS? |
| 129 | +You can achieve this by setting the animation-direction property to alternate or alternate-reverse. */ |
0 commit comments