.head{ position: absolute; -webkit-animation: shake 1s infinite; -webkit-transform-origin: center bottom; } @-webkit-keyframes shake{ 0% { -webkit-transform:rotate(-5deg); } 50% { -webkit-transform:rotate(5deg); } 100% { -webkit-transform:rotate(-5deg); } }
CSS3 @keyframes 用法:
http://www.w3school.com.cn/cssref/pr_keyframes.asp
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> <style> .head{ position: absolute; -webkit-animation: shake 1s infinite; -webkit-transform-origin: center bottom; } @-webkit-keyframes shake{ 0% { -webkit-transform:rotate(-5deg); } 50% { -webkit-transform:rotate(5deg); } 100% { -webkit-transform:rotate(-5deg); } }} } </style> </head> <body> <div class="head"><img src="http://img.xiami.net/res/loop/img/avatar/head_back_girl.png" class="head_img"></div> </body> </html>
在线DEMO: http://jsbin.com/vaqicejapa
时间: 2024-10-07 00:24:43