PHP & JavaScript Room :: 設置サンプル

実行結果

設置サンプル

参照:Garage Door Style Menu (using Animated Background Images with jQuery)

▼マウスオーバーすると、シャッターのように開いて画像が見えます。マウスアウトすると閉じます。

設置サンプルのソース

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="ja" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="imagetoolbar" content="no" />
      <title>設定サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <!-- JS -->
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript" src="/content/lib/jquery/jquery.backgroundPosition.js"></script>
      <script type="text/javascript">
         $(function(){
            //Set css in Firefox (Required to use the backgroundPosition js)
            $('#shutter1').css({backgroundPosition: '0px 0px'});
            $('#shutter2').css({backgroundPosition: '0px 0px'});
            $('#shutter3').css({backgroundPosition: '0px 0px'});
            $('#shutter4').css({backgroundPosition: '0px 0px'});
            //Animate the shutter
            $(".link").hover(function(){
                  $(this).parent().stop().animate({backgroundPosition: '(0px -100px)'}, 500 );
                }, function() {
                  $(this).parent().stop().animate({backgroundPosition: '(0px 0px)'}, 500 );
            }); 
         });
      </script>
      <!-- CSS -->
      <style type="text/css">
         ul#menuback { margin:0;padding:0; list-style:none; background:url("/content/img/ajax/garage_door_style_menu/menu-bg.jpg"); width:800px; overflow:hidden; }
         ul#menuback li { margin:0; padding:0; }
         ul#menuback li.shutter { width:200px; height:100px; display:block; float:left; }
         ul#menuback li#shutter1 { background:url("/content/img/ajax/garage_door_style_menu/shutter-1.jpg") no-repeat; }
         ul#menuback li#shutter2 { background:url("/content/img/ajax/garage_door_style_menu/shutter-2.jpg") no-repeat;  }
         ul#menuback li#shutter3 { background:url("/content/img/ajax/garage_door_style_menu/shutter-3.jpg") no-repeat; }
         ul#menuback li#shutter4 { background:url("/content/img/ajax/garage_door_style_menu/shutter-4.jpg") no-repeat; }
         a.link { width:200px; height:100px; display:block; background:url("/content/img/ajax/garage_door_style_menu/window.png") no-repeat bottom center; text-indent:-9999px; }
      </style>
   <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
   <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1>設置サンプル</h1>
         <p>参照:<a href='http://css-tricks.com/garage-door-style-menu-using-animated-background-images-with-jquery/'>Garage Door Style Menu (using Animated Background Images with jQuery)</a></p>
         <p>▼マウスオーバーすると、シャッターのように開いて画像が見えます。マウスアウトすると閉じます。</p>
<!-- CODE -->
         <ul id="menuback">
            <li class="shutter" id="shutter1"><a class="link" href="#1">Link 1</a></li>
            <li class="shutter" id="shutter2"><a class="link" href="#2">Link 2</a></li>
            <li class="shutter" id="shutter3"><a class="link" href="#3">Link 3</a></li>
            <li class="shutter" id="shutter4"><a class="link" href="#4">Link 4</a></li>
         </ul>
<!-- CODE / -->
      </div>
   </body>
</html>