基于CSS3的animation屬性實(shí)現(xiàn)微信拍一拍動(dòng)畫效果
發(fā)布時(shí)間:2020-06-22 14:52:48 作者:sin45。
我要評(píng)論
這篇文章主要介紹了基于CSS3的animation屬性實(shí)現(xiàn)微信拍一拍動(dòng)畫效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
看到最近流行的微信拍一拍功能,復(fù)習(xí)下CSS3的animation,所以寫下這個(gè)盒子晃動(dòng)的動(dòng)畫,把qq的窗口抖動(dòng)也加上吧
@-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;
}
/*活動(dòng)搖擺動(dòng)畫*/
@-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窗口抖動(dòng) -->
<div class="shake">qq窗口抖動(dòng)</div>
<!-- 微信拍拍頭像晃動(dòng) -->
<div class="stagger">微信拍拍頭像晃動(dòng)</div>
document.querySelector('.stagger').addEventListener('click', function() {
document.querySelector('.stagger').classList.add('stagger1')
console.log('papa nudged baby')
})
/*每次點(diǎn)擊實(shí)現(xiàn)動(dòng)畫,注意監(jiān)聽動(dòng)畫結(jié)束,移除動(dòng)畫類,后再添加動(dòng)畫類
document.querySelector('.stagger').addEventListener('animationend', function() {
document.querySelector('.stagger').classList.remove('stagger1')
})
到此這篇關(guān)于基于CSS3的animation屬性實(shí)現(xiàn)微信拍一拍動(dòng)畫效果的文章就介紹到這了,更多相關(guān)css3 微信拍一拍功能內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
相關(guān)文章

CSS3動(dòng)畫之利用requestAnimationFrame觸發(fā)重新播放功能
這篇文章主要介紹了利用requestAnimationFrame重新播放(觸發(fā))CSS3動(dòng)畫,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-09-11css動(dòng)畫屬性使用及實(shí)例代碼(transition/transform/animation)
這篇文章主要介紹了css動(dòng)畫屬性使用及實(shí)例代碼(transition/transform/animation) ,需要的朋友可以參考下2019-05-09CSS3中動(dòng)畫屬性transform、transition和animation屬性的區(qū)別
最近在項(xiàng)目中用到了CSS3中的動(dòng)畫屬性。無奈對(duì)于css3幾個(gè)新加的屬性不太熟悉,常常容易搞混。所以從網(wǎng)站研究了點(diǎn)資料,總結(jié)一下,方便有需要的朋友們可以參考學(xué)習(xí)。2016-09-25css動(dòng)畫效果之a(chǎn)nimation的常用樣式
這篇文章主要介紹了css動(dòng)畫效果之a(chǎn)nimation的常用樣式,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2020-08-11


