button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
animation: button 1s ease-in-out infinite;
@keyframes button {
0% {
background-color: #4CAF50;
50% {
background-color: #3F51B5;
100% {
background-color: #4CAF50;
在这个例子中,使用@keyframes语句定义了按钮的样式。该样式定义了按钮从0%到50%的颜色变化,然后从100%回到0%。使用@keyframes语句时,需要确保定义的规则的名称和参数正确。