In daily development, front-end students often argue over some animations and designs. The designers want to implement them with code, while the front-end designers want to design gif images. In the end, no one gives in, the designers leave, and the front-end designers are left to work overtime alone... CSS technology is a skill that must be mastered by the front-end. Not only must it be mastered, but it must also be proficient in. With the current trend of front-end frameworks being prevalent, programmers have fewer and fewer opportunities to write styles. With component-based development, there is hardly a need to write a single line of CSS code for a page. Even if you don't write it, you must understand the principle behind it. From the perspective of web page performance, animations that can be implemented with CSS should never use JS, and animations that can be implemented with JS should never use GIF. When executing animations, CSS can call the machine's GPU to execute, so its performance is naturally much better than JS. The above TikTok text shaking can be achieved using CSS animation by changing the shadow direction of the text and setting the blur effect of the looped animation frame. Knowing the principle will be much simpler. You might as well think about it more often in your daily life. The effect diagram is as follows: Attach the code body { margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #000; } h2 { color: #fff; font-family: sans-serif; font-size: 4em; animation: animate 0.5s linear infinite; } @keyframes animate { 0%, 100% { text-shadow: -1.5px -1.5px 0 #0ff, 1.5px 1.5px 0 #f00; } 25% { text-shadow: 1.5px 1.5px 0 #0ff, -1.5px -1.5px 0 #f00; } 50% { text-shadow: 1.5px -1.5px 0 #0ff, 1.5px -1.5px 0 #f00; } 75% { text-shadow: -1.5px 1.5px 0 #0ff, -1.5px 1.5px 0 #f00; } } This concludes this article about how to use CSS to implement TikTok text shaking effects. For more relevant CSS text shaking content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Web front-end skills summary (personal practical experience)
>>: 【HTML element】Detailed explanation of tag text
As we all know, without the cd command, we cannot...
Method 1: Using the onclick event <input type=...
1. Introduction Vagrant is a tool for building an...
Preface All requests in Tomcat are handled by Ser...
When compiling and installing Nginx, some modules...
Use js to control the light switch for your refer...
Preface As we all know, bash (the B ourne-A gain ...
Table of contents webpack5 Official Start Buildin...
Demand Background Recently, I plan to use Vue and...
First, take a look at Alibaba Cloud's officia...
Table of contents 1. Where to write JavaScript 2....
Table of contents Preface $attrs example: $listen...
This article is compiled with reference to the My...
I remember that a few years ago, there was an int...
Since PHP7 came out, as a fan of the latest versi...