Jquery-effect-size

提供:Dev Guides
移動先:案内検索

jQuery効果-サイズ効果

説明

*Size* エフェクトは、effect()メソッドで使用できます。 これにより、指定された幅と高さに要素のサイズが変更されます。

構文

この効果を使用するための簡単な構文は次のとおりです-

selector.effect( "size", {arguments}, speed );

パラメーター

ここにすべての引数の説明があります-

  • from -開始時の状態、通常は必要ありません。 これは、\ {height:..、width:..という形式のオブジェクトです。 }
  • to -サイズ変更する高さと幅。 これは、\ {height:..、width:..という形式のオブジェクトです。 }
  • origin -消失点、表示/非表示のデフォルト。 これは配列で、デフォルトは['middle'、 'center']です。
  • scale -要素のどの領域がサイズ変更されるか: 'both'、 'box'、 'content' Boxは要素の境界とパディングのサイズを変更しますContentは要素内のコンテンツのサイズを変更します。 デフォルトは「両方」です。

以下は、この効果の使用法を示す簡単な例です-

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>

      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      </script>

      <script type = "text/javascript" language = "javascript">

         $(document).ready(function() {

            $("#big").click(function(){
               $(".target").effect( "size", { to: {width: 200,height: 200} }, 1000 );
            });

            $("#small").click(function(){
               $(".target").effect( "size", { to: {width: 10,height: 10} }, 1000 );
            });

         });

      </script>

      <style>
         p {background-color:#bca; width:200px; border:1px solid green;}
         div{ width:100px; height:100px; background:red;}
      </style>
   </head>

   <body>
      <p>Click any of the buttons</p>

      <button id = "big"> Big </button>
      <button id = "small"> Small </button>

      <div class = "target">
      </div>
   </body>
</html>

これにより、次の結果が生成されます–