How to use CSS to make text to realize frame-by-frame animation
This article mainly introduces how to use CSS to make text to achieve frame-by-frame animation, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Methods and steps
HTML part
1. Create a html to define a div headline that contains text and use the class attribute to style.
Html Editing Code example
Nicknamed too strong
Code effect
The Html editor has written it and then uses the css style to decorate it.
CSS part
1. Add a background color to the web page
Body {background:#333;}
2. Cell title text style, using the dashed attribute to add the style and color of the element border, and using the position:absolute attribute to be absolutely positioned in the middle.
Code example
.cell {width: 1em; height: 1em; border:1px dashed rgba (255pr. 255, 255L. 01m); font-size:120px; font-family:Frijole; overflow: hidden; position:absolute; top:50%; left:50%; margin:-0.5em 0 0-0.5m; opacity:0; animation:go 6s; transform-origin:left bottom;}
3. The num title text style uses the animation attribute steps () to animate frame by frame, the text-shadow attribute to add text shadow and color, and the position:absolute attribute to be absolutely positioned in the middle.
.num {position:absolute; width: 1em; color:#E53F39; line-height: 1em; text-align: center; text-shadow:1px 1px 2px rgba (255pr. 255pr. 3); animation:run 6s steps (6);}
Next, we add animation effects to make the text dynamic to achieve frame-by-frame animation.
Bind animation animation to the num tag.
Using the two @ keyframes rules, you can set the action for each frame of the two animations.
@ keyframes run {0% {top:0;} 100% {top:-6em;}} @ keyframes go {0% {opacity:1;} 84% {opacity:1;transform:rotate (0deg) scale (1);} 100% {opacity:0;transform:rotate (360deg) scale (.01);}}
Final effect
The complete code is given below
Body {background:#333;} .cell {width: 1em; height: 1em; border:1px dashed rgba (255pcm.255rep 0.1mm); font-size:120px; font-family:Frijole; overflow: hidden; position:absolute; top:50%; left:50%; margin:-0.5em 00-0.5emm; opacity:0; animation:go 6s; transform-origin:left bottom;} .num {position:absolute Width: 1mm; color:#E53F39; line-height: 1em; text-align: center; text-shadow:1px 1px 2px rgba (255pr. 255Power.3); animation: blue 6s steps (1);} @ keyframes run {0% {top:0;} 100% {top:-6em;}} @ keyframes go {0% {opacity:1;} 85% {opacity:1;transform:rotate (0deg) scale (1);} 100% {opacity:0 Transform:rotate (360deg) scale (.01);} is too much to thank you for reading this article carefully. I hope the article "how to use CSS to make text to realize frame-by-frame animation" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!