<style>
  * {
    box-sizing: border-box;
  }
  html, body {
    align-items: center;
    background: linear-gradient(45deg, rebeccapurple, dodgerblue);
    color: #fff;
    display: flex;
    flex-direction: column;
    font-family: 'Arial', sans-serif;
    justify-content: center;
    margin: 0;
    min-height: 100vh;
    padding: 0;
    width: 100vw;
  }
  input {
    margin: 4px;
  }
  input, label {
    cursor: pointer;
  }
  div {
    background-color: #2eec71;
    height: 100px;
    margin-top: 50px;
    width: 100px;
  }
</style>
<label for="play">
  Playing
</label>
<input id="play" type="checkbox" checked/>
<div></div>
div {
  animation-name: spin;
  animation-duration: 2s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
  animation-play-state: paused;
}

:checked ~ div {
  animation-play-state: running;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.