A quick start guide to CSS animations πŸ‘‡πŸ»

Thread 🧡
Animations on your web pages or website can catch more audience

You can create some amazing animation using CSS itself. In this thread, we will try to learn some decent knowledge about it

Let's start πŸ‘‡πŸ»

{ 2 / 19 }
Animation is all about changing one style to another at certain intervals or times

For doing that, first and foremost thing which we need to learn is @ keyframes at rule

{ 3 / 19 }
Let's understand the keyframes syntax first (See attached image)

Confusing? Don't worry! Let's move further everything will be crystal clear

{ 4 / 19 }
animation property is used to bind keyframes with a particular element

For example, suppose I want to move my element 500px left in four seconds. It's very easy (check video in next tweet)

{ 5 / 19 }
The output of the above code

Play with code here codepen.io/prathamkumar/p…

{ 6 / 19 }
Alright moving further, we can also pass percentage in keyframes rule and make some amazing animations

For example, suppose I want on change the background-color of an element

{ 7 / 19 }
One thing you might noticed here is that I'm using animation property only and passing multiple values in that. Like

animation: move 4s;

This is because animation is a shorthanf for setting all animation properties

{ 8 / 19 }
You can also specify the delay in your animation using animation delay property.

It specifies a delay before the start of an animation

{ 9 / 19 }
So far we have noticed that our animation only happens only once.

This is becuase we haven't applied the animation-iteration-count property

It specifies the number of times an animation should run.

For ex, animation-iteration-count: 5
(You can also pass infinite)

{10 / 19}
Creating a smooth animation is important and we have

animation-timing-function property for that.

This property specifies the speed curve of an animation. There are many functions that you can pass in this

{ 11 / 19 }
You can pass following values in animation-timing function

- ease (slow start, then fast, then slow)
- linear (same speed)
- ease-in (slow start)
- ease-out (slow end)
- ease-in-out (slow start and slow end)
- cubic-bezier (customizable)

{ 12 / 19 }
Check out this code and output for better understanding

codepen.io/prathamkumar/p…

{ 13 / 19 }
One thing to note here is that animation do not affect element before or after the keyframes.

In order to persist the styling based on last or first keyframe, we have animation-fill-mode

{ 14 / 19 }
It accepts following value

- forwards (element will retain last keyframe styling)
- backwards (element will get the first keyframe value even in animation-delay period)
- both (both of the above)

{ 15 / 19 }
Let's play with animation-fill-mode

As you can blue box stopped at left: 500px becuase forwards is begin applied on it
And orange box has black background even it's in a delay period of 2 seconds

Check code for better understanding
codepen.io/prathamkumar/p…

{ 16 / 19 }
Instead for using different animation properties you can use shorthand "animation" only

For example πŸ‘‡πŸ»

{ 17 / 19 }
This may seems little tough initially but practice of 2 - 3 days can make it easier.

Play around with code and try to write code by your own. This will definitely help you

codepen.io/prathamkumar/p…

{ 18 / 19 }
This is pretty much it I guess. I hope you get some knowledge from this thread.

If you like it, share this thread with your connections, it means a lot to me ❀️

And thank for reading it πŸ˜„

*** END ***

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Pratham πŸ‘¨β€πŸ’»πŸš€

Pratham πŸ‘¨β€πŸ’»πŸš€ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Prathkum

1 Mar
6 GitHub repositories that can help you as a developer

🧡 πŸ‘‡πŸ»
πŸ“Œ Art of Command Line

Learning command line interface is always beneficial for developer. In this repo you'll find different section for Linux, windows and MAC commands

github.com/jlevy/the-art-…
πŸ“Œ Front-end Developers Bookmarks

A huge collection of resources for frontend web developers including appearance, architecture, compatibility etc

github.com/dypsilon/front…
Read 10 tweets
28 Feb
useReducer Hook - an alternative to useState
useReducer is preferable to useState when you have some complex state.

It accepts three parameter out of which two are mandatory I guess

The first one is reducer function and second one is initial state
useReducer returns two things

- The first one in current state
- The second one is a dispatch function using which you can change your current state by passing action type is dispatch.
Read 4 tweets
28 Feb
I have covered some important CSS topics in my thread in last couple of days.

Here is a quick sneak peek 🧡
πŸ“Œ Relative and Absolute positioning

Read 16 tweets
27 Feb
A quick guide to CSS Grid layout πŸ‘‡πŸ»

Thread🧡
Grid is used for making complex web design layouts more easily as it's not so hard to master

Using Flex you can make only 1D layout but Grid gives you full power of creating 2D layout

Let's start β˜•

{ 2 / 17 }
First things first, start with giving the display property "grid" to the container element or parent element

{ 3 / 17 }
Read 18 tweets
26 Feb
Some general tips for writing an effective tweet or thread

🧡 πŸ‘‡πŸΌ
1️⃣ Write about the things you are good at

I always try to write tweets related to web technologies. More specifiy I try to cover CSS, JavaScript and React. By writing about the stuff that you're good, you can share huge amount of knowledge from your tweet

{ 2 / 10 }
2️⃣ Support your point with an example

If you're writing about some coding tips or tricks, It would be great if you give a example in the form of image, video, gif or link

{ 3 / 10 }
Read 10 tweets
25 Feb
Web development resources for free

Mega Thread 🧡 πŸ‘‡πŸ»
1️⃣ Online learning platforms πŸ“˜

- Udemy
- FreeCodeCamp
- Treehouse
- Frontend masters
- Coursera
- Traversy media
- SoloLearn
- Codecademy
- Udacity
- Alison
- Code college
- LinkedIn Learning
- Skillshare
- EdX
2️⃣ Editors and share code snippets ✍🏻

- PlayCode
- JSFiddle
- CodePen
- StackBlitz
- JSBin
- Codesandbox
- Codeinterview .io
- godbolt .org
- wandbox .org
- carbon .now.sh
- pastebin .com
- ideone .com
- ide .judge0.com
Read 24 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!