usualoma
12/2/2015 - 8:24 PM

animation.html.erb

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
    body {
      user-select: none;
      -moz-user-select: none;
      -webkit-user-select: none;
      -ms-user-select: none;
    }

    label {
      display: block;
      width: 290px;
      height: 280px;
      position: absolute;
      z-index: 1;
      background: rgb(230, 230, 230);
      text-align: center;
    }

    #bird {
      position: absolute;
      background-image: url(./images/bird.png);
      width: 36px;
      height: 26px;
      top: 260px;
      left: 125px;
      z-index: 3;
      animation-name: jump;
      animation-duration: 2s;
      animation-iteration-count: infinite;
      animation-timing-function: linear;
      animation-play-state: paused;
    }

    @keyframes jump {
      0%   { top: 260px }
      50%  { top:   0px }
      100% { top: 260px }
    }

    #start:checked ~ #bird {
      animation-play-state: running;
    }

    #start:checked ~ #label-stop {
      z-index: 2;
    }

    #stop:checked ~ #bird {
      animation-play-state: paused;
    }

    #stop:checked ~ #label-start {
      z-index: 2;
    }
    </style>
  </head>
  <body>
    <input type="radio" name="action" id="start" />
    <input type="radio" name="action" id="stop" />

    <label for="stop" id="label-stop">&lt;for="stop" id="label-stop"&gt;</label>
    <label for="start" id="label-start">&lt;for="start" id="label-start"&gt;</label>

    <div id="bird"></div>
  </body>
</html>