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

実行結果

設置サンプル

参照:Image Zoom Effect 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" />
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
      <script type="text/javascript">
         $(function(){
            $('a.zoom').each(function() {
               var oheight = $(this).children(0).height();
               var owidth = $(this).children(0).width();
               var nheight = (oheight + (oheight * 0.25));
               var nwidth = (owidth + (owidth * 0.25));
               var top = ((oheight - nheight) / 2);
               var left = ((owidth - nwidth) / 2);
               $(this).mouseenter(function() {
                  $(this).css('z-index', '10').children(0).stop().animate({
                        'height' : nheight+'px',
                        'width' : nwidth+'px',
                        'left' : left+'px',
                        'top' : top+'px'}, 210);
               });
               $(this).mouseleave(function() {
                  $(this).children(0).stop().animate({
                        'left' : '0px',
                        'top' : '0px',
                        'height' : oheight+'px',
                        'width' : owidth+'px'}, 150, function() {
                           $(this).css('height', oheight+'px').parent().css('z-index', '1');
                        });
               });
               $(this).click(function() {
                  return false;
               });
            });   
         });
      </script>
      <style type="text/css">
         #demo {
            height:300px;
            width: 300px;
            margin: 0 auto;
         }
         #demo a img  {
            position:relative;
            z-index:1;
         }
      </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://return-true.com/2010/08/image-zoom-effect-with-jquery/' target='_blank'>Image Zoom Effect With jQuery</a></p>
         <p>▼サムネイル画像にマウスオーバーすると、原寸大画像をズームアップ表示。</p>
<!-- CODE -->
<div id="demo">
   <a href="#" class="zoom"><img src="http://farm2.static.flickr.com/1164/5157648985_87c8a86b9f.jpg" width="300" height="300" /></a>
</div>
<!-- / CODE -->
      </div>
   </body>
</html>