<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>闹钟震动</title>
<style>
#div1
{
position: relative;
height: 200px;
width: 200px;
margin: 100px;
border: 1px solid black;
}
#div2
{
display: flex;
justify-content: center;
align-items: center;
margin: 50px;
width: 100px;
height: 100px;
border: 1px solid black;
background-color: red;
animation: myfirst 5s;
}
@keyframes myfirst
{
0% {
transform: rotate(-15deg);
}
2% {
transform: rotate(15deg);
}
4% {
transform: rotate(-18deg);
}
6% {
transform: rotate(18deg);
}
8% {
transform: rotate(-22deg);
}
10% {
transform: rotate(22deg);
}
12% {
transform: rotate(-18deg);
}
14% {
transform: rotate(18deg);
}
16% {
transform: rotate(-12deg);
}
18% {
transform: rotate(12deg);
}
20% {
transform: rotate(0deg);
}
}
</style>
</head>
<body>
<div id="div1">
<div id="div2">闹钟</div>
</div>
</body>
</html>