javascript - How to make transition go back and forth once -
i've heard of animations/transitions occur multiple times. need transition changes width once , changes (again, on three-second interval) after two-second pause. how this?
here's code:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>page 2</title> <style type="text/css"> /* styles go here */ img { width:200px; height:100px; animation-name: widthchange; animation-duration: 3s; -webkit-animation-name: widthchange; -webkit-animation-duration: 3s; -moz-animation-name: widthchange; -moz-animation-duration: 3s; -0-animation-name: widthchange; -0-animation-duration: 3s; } p {text-align:center} button {margin:20px} .stylized { font-style: italic; border-width: 5px; border-color: yellow; border-style: outset; } @-webkit-keyframes widthchange { {width: 200px;} {width: 400px;} {width: 400px;} {width: 200px;} } @-o-keyframes widthchange { {width: 200px;} {width: 400px;} {width: 400px;} {width: 200px;} } @-moz-keyframes widthchange { {width: 200px;} {width: 400px;} {width: 400px;} {width: 200px;} } @keyframes widthchange { {width: 200px;} {width: 400px;} {width: 400px;} {width: 200px;} } </style> <script src="http://code.jquery.com/jquery.min.js"></script> <script type="text/javascript"> $(function(){ // jquery methods go here... $(document).ready(function() { $('img').addclass("loaded"); $('img').addclass("loaded2"); $("#button1").click(function() { $("button").addclass("stylized"); $("#button1").html("fancy button 1"); $("#button2").html("fancy button 2"); $("#button3").html("fancy button 3"); }); }); }); /* additional javascript goes here */ </script> </head> <body> <img class = "image" src="elephant.jpg" alt="elephant"/> <p><button id="button1">button 1</button><button id="button2">button 2</button><button id="button3">button 3</button></p> </body> </html>
img { width:200px; height:100px; animation: widthchange 3s 2s; -webkit-animation: widthchange 3s 2s; -moz-animation: widthchange 3s 2s; -0-animation: widthchange 3s 2s; } p {text-align:center} button {margin:20px} .stylized { font-style: italic; border-width: 5px; border-color: yellow; border-style: outset; } @-webkit-keyframes widthchange { 0%, 100% {width: 200px;} 50% {width: 400px;} } @-o-keyframes widthchange { 0%, 100% {width: 200px;} 50% {width: 400px;} } @-moz-keyframes widthchange { 0%, 100% {width: 200px;} 50% {width: 400px;} } @keyframes widthchange { 0%, 100% {width: 200px;} 50% {width: 400px;} }
<img class = "image" src="elephant.jpg" alt="elephant"/> <p><button id="button1">button 1</button><button id="button2">button 2</button><button id="button3">button 3</button></p>
use %
, animation-delay
Comments
Post a Comment