當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JQuery UI Size效果用法及代碼示例

Size Effect

說明:將元素調整為指定的寬度和高度。

  • size
    • to
      類型:Object
      要調整大小的高度和寬度。
    • origin(默認:[ "top", "left" ])
      類型:Array
      消失點。
    • scale(默認:"both")
      類型:String
      元素的哪些區域將調整大小:"both""box""content"。 Box 調整元素的邊框和內邊距; content 調整元素內任何內容的大小。

當將此效果與 .show() .toggle() 方法一起使用時,to 參數用作起點,原始大小用作終點。

例子:

使用尺寸效果調整元素的大小。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>size demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
  <style>
  #toggle {
    width: 100px;
    height: 100px;
    background: #ccc;
  }
  </style>
  <script src="//code.jquery.com/jquery-1.12.4.js"></script>
  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
 
<p>Click anywhere to resize the box.</p>
<div id="toggle"></div>
 
<script>
$( document ).click(function() {
  $( "#toggle" ).effect( "size", {
    to: { width: 200, height: 60 }
  }, 1000 );
});
</script>
 
</body>
</html>

演示:

相關用法


注:本文由純淨天空篩選整理自jqueryui.com大神的英文原創作品 Size效果。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。