ã·ã³ãã«ãªäºã¯JQueryã ãã§ãã£ãæ¹ãè¯ãï¼ -- ç»åãã¹ã©ã¤ãããã¨ãã§ã¯ã
ã客æ§ã®è¦æã§ãç»é¢ä¸ã§ç»åãã¹ã©ã¤ããã Javascriptãä½ãã¾ããã
ã㢠â http://ey-office.net/samples/090523/slider.html
æåã¯ãJQueryã®ãã©ã°ã¤ã³ãæ¢ãã¦ä½¿ã£ã¦ã¿ãã®ã§ãããã©ããæ©è½ãå¤ããã¦ãã¾ã²ã¨ã¤ã§ããã
ããã§è²ã
ã¨èª¿ã¹ã¦ã¿ãã¨ãQueryã® animate()㨠CSS ã® overflow: hidden ãçµã¿åãããã¨ç°¡åã«åºæ¥ãããªã®ã§ä½ã£ã¦ã¿ã¾ãã(æ¢ã«ããããã®æ¹ãä½ã£ã¦ãã¨æãã¾ããã»ã»ã»)
ä»åãåå¼·ã«ãªã£ãäºã¨ãã¦ã¯ãã·ã³ãã«ãªäºã¯JQueryã ãã§ãã£ãæ¹ãè¯ãã¨ãããã¨ã§ããã
ãã©ã°ã¤ã³ã¯é©å½ãªãã®ãæ¢ãã®ã«ããèªåã®ãããã¨ãã¦ããäºãåºæ¥ãã®ãæ¤è¨¼ããã®ã«ãæ¡å¤ã¨æéããããã¾ãããããªãã¨ã«æéã使ããªãã¦ã JQuery ã¯ãã¼ã¹ã ãã§ãçµæ§å¼·åã§ã ^^)
ã³ã¼ã
<html> <head> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <style type="text/css"> div#photo { background-image: url(init.png); background-position: 0px 0px; overflow: hidden; width: 211px; height: 141px; margin: 20px; } </style> </head> <body> <div id="photo"></div> <button id="action"> Action </button> </body> <script type="text/javascript"> $("#action").click(function(){ $("#photo").css("background-image", "url(slider.png)"); $("#photo").animate({backgroundPosition: '-534px 0px'}, 2000); }); </script> </html>