<div class="container">
  <button>Shrink</button>
</div>
/* 定义动画属性 */
button {
  /*  动画名称: shrink  */
  animation-name: shrink;
  /*  动画持续时间: 0.5秒 */
  animation-duration: .5s;
  /*  动画的循环次数: 无限次  */
  animation-iteration-count: infinite;
  /*  循环是否反向:先正向后反向  */
  animation-direction: alternate;
  /*  简写形式  */
  /*  animation: shrink .5s linear alternate infinite; */
}

/* 定义关键帧 */
@keyframes shrink {
  0% {
    -webkit-transform: scale(1);
    transform: scale(1);
  }
  100% {
    -webkit-transform: scale(0.8);
    transform: scale(0.8);
  }
}

/* 初始化 */
* {
  margin: 0;
  padding: 0;
}
.container {
  width: 100vw;
  height: 100vh;
  background-color: #f1f1f1;
  position: relative;
}
button {
  width: 100px;
  height: 30px;
  border-radius: 5px;
  position: absolute;
  top: 0;
  right: 0; 
  bottom: 0; 
  left: 0;
  margin: auto;
  border: 1px solid;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.