Skip to content

Commit f516986

Browse files
authored
Update animate-images-with-keyframes-using-css.mdx
1 parent d5c206c commit f516986

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

projects/animate-images-with-keyframes-using-css/animate-images-with-keyframes-using-css.mdx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,61 @@ The result of the club penguin sensei looks like this 🔥🔥
179179

180180
<RoundedImage link="https://i.imgur.com/YVnPHFA.gif" description="spinning club penguin sensei" />
181181

182+
## Hovering Animation
183+
184+
Imagine you're playing a video game and you're choosing which character to play as, or you're in an idle mode.
185+
186+
<RoundedImage link="https://i.imgur.com/PVfHyBD.gif" description="game mode idle hovering player" />
187+
188+
This is a hovering animation that we can create with keyframes!
189+
190+
```
191+
<div className="sensei">
192+
<img src="sensei.png" alt="club penguin gray sensei penguin" />
193+
</div>
194+
```
195+
```
196+
/* bouncing animation (floating) */
197+
@keyframes bounce {
198+
0%, 100% {
199+
transform: translateY(0);
200+
}
201+
50% {
202+
transform: translateY(-30px);
203+
}
204+
}
205+
206+
.sensei {
207+
animation: bounce 1s linear infinite;
208+
display: flex;
209+
justify-content: center;
210+
align-items: center;
211+
height: 100vh;
212+
}
213+
```
214+
215+
Here, we're translating (aka moving) the object's Y position by 30 pixels halfway through the animation, and returning it to its original spot at the end using a `linear` ease.
216+
217+
The beautiful result:
218+
219+
<RoundedImage link="https://i.imgur.com/69VUqyO.gif" description="club penguin sensei hovering" />
220+
221+
222+
To achieve this animation speed, we set the length of time to `1s`, but you can play around with this value to get the effect you want!
223+
224+
225+
## Conclusion
226+
227+
Congrats! You've learned the basics of CSS image animation, and as you can tell, it's a world of opportunities to add flair to your website or project! ✨✨✨
228+
229+
<RoundedImage link="https://i.imgur.com/7QS4kBF.gif" description="pokemon flying" />
230+
231+
Some other ways you can animate images include:
232+
233+
- bounce effect
234+
- heartbeat pulse
235+
- zoom in/out
236+
- shake or vibration
237+
- pop on hover
238+
- wave effect
239+
- + many more!

0 commit comments

Comments
 (0)