Implementing WeChat tap animation effect based on CSS3 animation attribute

Implementing WeChat tap animation effect based on CSS3 animation attribute

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

>>:  Solution to automatically submitting the form and jumping to other pages after pressing Enter on the web page

Recommend

Summary of standard usage of html, css and js comments

Adding necessary comments is a good habit that a ...

Learn the basics of nginx

Table of contents 1. What is nginx? 2. What can n...

Best Practices Guide for MySQL Partitioned Tables

Preface: Partitioning is a table design pattern. ...

Introduction to query commands for MySQL stored procedures

As shown below: select name from mysql.proc where...

Detailed explanation of Vue's monitoring properties

Table of contents Vue monitor properties What is ...

Nginx monitoring issues under Linux

nginx installation Ensure that the virtual machin...

Implementing custom radio and check box functions with pure CSS

1. Achieve the effect 2 Knowledge Points 2.1 <...

MySQL data type optimization principles

MySQL supports many data types, and choosing the ...

Reduce memory and CPU usage by optimizing web pages

Some web pages may not look large but may be very ...

How to get datetime data in mysql, followed by .0

The data type of MySQL is datetime. The data stor...

In-depth understanding of umask in new linux file permission settings

Preface The origin is a question 1: If your umask...

Detailed explanation of using scp command to copy files remotely in Linux

Preface scp is the abbreviation of secure copy. s...

Detailed explanation of Nginx process management and reloading principles

Process structure diagram Nginx is a multi-proces...

Detailed analysis of the usage and application scenarios of slots in Vue

What are slots? We know that in Vue, nothing can ...