Seeing the recent popular WeChat tap function, I reviewed the CSS3 animation, so I wrote this box shaking animation and added the QQ window shaking. @-webkit-keyframes shake { 0% { -webkit-transform: translate(2px, 2px); } 25% { -webkit-transform: translate(-2px, -2px); } 50% { -webkit-transform: translate(0px, 0px); } 75% { -webkit-transform: translate(2px, -2px); } 100% { -webkit-transform: translate(-2px, 2px); } } @keyframes shake { 0% { transform: translate(2px, 2px); } 25% { transform: translate(-2px, -2px); } 50% { transform: translate(0px, 0px); } 75% { transform: translate(2px, -2px); } 100% { transform: translate(-2px, 2px); } } .shake { position: relative; top: 30px; left: 100px; height: 200px; width: 200px; color: #ff0000; background: #000; } .shake:hover { -webkit-animation: shake 0.2s infinite; animation: shake 0.2s infinite; } /*Activity swing animation*/ @-webkit-keyframes swing { 10% { transform: rotate(15deg); } 20% { transform: rotate(-10deg); } 30% { transform: rotate(5deg); } 40% { transform: rotate(-5deg); } 50%,100% { transform: rotate(0deg); } } @-moz-keyframes swing { 10% { transform: rotate(15deg); } 20% { transform: rotate(-10deg); } 30% { transform: rotate(5deg); } 40% { transform: rotate(-5deg); } 50%,100% { transform: rotate(0deg); } } @-o-keyframes swing { 10% { transform: rotate(15deg); } 20% { transform: rotate(-10deg); } 30% { transform: rotate(5deg); } 40% { transform: rotate(-5deg); } 50%,100% { transform: rotate(0deg); } } @keyframes swing { 10% { transform: rotate(12deg); } 20% { transform: rotate(-11.5deg); } 30% { transform: rotate(1deg); } 40% { transform: rotate(-1deg); } 50%,100% { transform: rotate(0.5deg); } } .stagger { background-color: #ff0000; width: 60px; height: 60px; } .stagger1{ animation: swing .5s .15s linear 1; /* animation-play-state: paused; */ } <!-- qq window shakes--> <div class="shake">qq window shake</div> <!-- WeChat avatar shaking--> <div class="stagger">WeChat pat avatar shaking</div> document.querySelector('.stagger').addEventListener('click', function() { document.querySelector('.stagger').classList.add('stagger1') console.log('papa nudged baby') }) /*Each click implements the animation, pay attention to the end of the monitoring animation, remove the animation class, and then add the animation class document.querySelector('.stagger').addEventListener('animationend', function() { document.querySelector('.stagger').classList.remove('stagger1') }) This is the end of this article about how to implement WeChat tap animation effects based on CSS3 animation attributes. For more relevant CSS3 WeChat tap function content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: SQL ROW_NUMBER() and OVER() method case study
Adding necessary comments is a good habit that a ...
Table of contents 1. What is nginx? 2. What can n...
Preface: Partitioning is a table design pattern. ...
As shown below: select name from mysql.proc where...
Table of contents Vue monitor properties What is ...
A: Usually stored in the client. jwt, or JSON Web...
nginx installation Ensure that the virtual machin...
1. Achieve the effect 2 Knowledge Points 2.1 <...
MySQL supports many data types, and choosing the ...
Some web pages may not look large but may be very ...
The data type of MySQL is datetime. The data stor...
Preface The origin is a question 1: If your umask...
Preface scp is the abbreviation of secure copy. s...
Process structure diagram Nginx is a multi-proces...
What are slots? We know that in Vue, nothing can ...