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

v-for directive in vue completes list rendering

Table of contents 1. List traversal 2. The role o...

A brief discussion on the pitfalls of react useEffect closure

Problem code Look at a closure problem code cause...

How to build your own Angular component library with DevUI

Table of contents Preface Creating a component li...

Detailed explanation of the function and usage of keepAlive component in Vue

Preface During the interview, many interviewers m...

A brief talk about Mysql index and redis jump table

summary During the interview, when discussing abo...

Example code of how CSS matches multiple classes

CSS matches multiple classes The following HTML t...

Zen coding resource update function enhancement

Official website: http://code.google.com/p/zen-cod...

Django online deployment method of Apache

environment: 1. Windows Server 2016 Datacenter 64...

Detailed explanation of mysql deadlock checking and deadlock removal examples

1. Query process show processlist 2. Query the co...

How to elegantly implement the mobile login and registration module in vue3

Table of contents Preface Input box component lay...

How to smoothly upgrade nginx after compiling and installing nginx

After nginx is compiled and installed and used fo...

Introducing ECharts into the Vue project

Table of contents 1. Installation 2. Introduction...

Pitfalls based on MySQL default sorting rules

The default varchar type in MySQL is case insensi...