👨💻 | How To Create Typewriter Effect Using Pure CSS
Hey There! 👋 Today in this guide we're going to tell you how can you create typewriter effect using css. there are a lot of different options are of doing it but using just pure css makes it simple & easy. Without wasting time let's get started!
Steps to Create Typewriter Effect Using CSS:
- Create a text element :
- Format It
- Animate it
- Done! Just run the code
First of all we need to create a text element here for example i'm going to create h1 tag as my text element and put text "Typewriter Effect" inside it as you can see below:
So before we will do anything its important to format it to look good. Here i am using some css properties below :
/*To Remove Extra Margin & Padding*/
/*To Align Body Content in Center*/
text-shadow:2px 2px #000;
That's it now I'm quite satisfied with little decent h1 styling, So move in to our important step and animate it to work.
Okay to create typewriter effect using css i am going to use animation property on text element to show Typewriter effect. Our code to animate text element goes like this :
/*To Hide overflows while typing*/
/*To save text from wrapping while effect*/
/*To Create Cursor*/
border-right:2px solid #000;
/*To Stay cursor at correct positio*/
/*animation name, time & function*/
animation:typing 2s steps(17) ;
/*animation : name duration steps(text length);*/
We had first attempt to hide any overflow of text while our animation using overflow property. Then we had used used warp property and no-wrap value to prevent text from wrapping while our animation starts.
we had used border-right property to create a cursor, and finally i had mentioned a animation property in which there is a animation name then duration then a function steps (to run it step by step smoothly) make sure get your text length before creating animation here my text length is 17 ch (characters), you had to replace your text length from all properties where we had mentioned 17. You can find your text length by just executing this simple code in console : "your text".length
Okay Enjoy you had learnt how to create typewriter effect with css.
Please share this post with your friends and bookmark our website for more informative content.
Don't forget us to follow on Instagram.