There is a requirement to realize the shaking effect of red envelopes. I have never done it before. I will record it. Hehe~~ .red_packet { width: 180rpx; height: 220rpx; position: fixed; top: 10rpx; right: 20rpx; color: #D60E19; animation: shake .5s linear infinite; } @keyframes shake { 25% { transform: rotate(7deg); } 75% { transform: rotate(-7deg); } 50%, 100% { transform: rotate(0); } } The effect that was initially achieved was like this It keeps swinging left and right, but the desired effect is to shake twice every few seconds. What should I do if animation does not support interval animation? After searching on Baidu, I found that by setting the percentage, the first three seconds will not move, and the shaking will start from 70%, and it must be fast, accurate and ruthless. After some improvement, the effect is as follows: .red_packet { width: 180rpx; height: 220rpx; position: fixed; top: 10rpx; right: 20rpx; color: #D60E19; animation: shake 3s linear infinite; } @keyframes shake { 70%, 80% { transform: rotate(7deg); } 75% { transform: rotate(-7deg); } 65%, 85% { transform: rotate(0); } } This is the end of this article about how to achieve red envelope shaking effect with CSS3. For more relevant CSS3 red envelope 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! |
<<: The process of installing Docker in Linux system
>>: Detailed explanation of CSS style sheets and format layout
This is a very important topic, not only for Linu...
HTML forms are used to collect different types of...
Table of contents 1. Simple mounting of persisten...
Recently, WeChat Mini Program has proposed adjust...
Mainly used knowledge points: •css3 3d transforma...
Table of contents Principle Source code analysis ...
What is Publish/Subscribe? Let me give you an exa...
"Development is more than just writing code&q...
This article example shares the specific code of ...
ElasticSearch cluster supports動態請求的方式and靜態配置文件to ...
In daily work, we sometimes run slow queries to r...
Preface: The previous article described several c...
Attribute check-strictly The official document pr...
If there is an <input type="image">...
Table of contents 1. Component Introduction 2. Co...