Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

ตัวอย่าง Keyframes พร้อมอนิเมชันเลื่อนซ้ายใน CSS3


ตัวอย่างด้านล่างแสดง height, width, color, name, และ duration ของอนิเมชันพร้อมไวยากรณ์ keyframes:

ตัวอย่าง

<html>
  <head>
    <style type="text/css">
      h1 {
        -moz-animation-duration: 3s;
        -webkit-animation-duration: 3s;
        -moz-animation-name: slidein;
        -webkit-animation-name: slidein;
      }
      @-moz-keyframes slidein {
        from {
          margin-left: 100%;
          width: 300%;
        }
        to {
          margin-left: 0%;
          width: 100%;
        }
      }
      @-webkit-keyframes slidein {
        from {
          margin-left: 100%;
          width: 300%;
        }
        to {
          margin-left: 0%;
          width: 100%;
        }
      }
    </style>
  </head>
  <body>
    <h1>Tutorials Point</h1>
    <p>this is an example of moving left animation.</p>
    <button onclick="myFunction()">Reload page</button>
    <script>
      function myFunction() {
        location.reload();
      }
    </script>
  </body>
</html>