jQuery UI API - 尺寸特效(Size Effect)

约 907 字 更新于 2026-11-18 5iyo.com

jQuery UI API - 尺寸特效(Size Effect)

所属类别

特效(Effects)

用法

描述:调整元素尺寸到指定宽度和高度。

size

参数 类型 描述 默认值
to Object 要调整到的高度和宽度。
origin Array 消失点。 [ "top", "left" ]
scale String 元素的哪个区域将被调整尺寸:"both"、"box"、"content"。当值为 "box" 时,调整元素的边框(border)和内边距(padding)的尺寸。当值为 "content" 时,调整元素内的所有内容的尺寸。 "both"

实例

使用尺寸特效(Size Effect)调整元素尺寸。


<!doctype html>

<html lang="en">

<head>

  <meta charset="utf-8">

  <title>尺寸特效(Size Effect)演示</title>

  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">

  <style>

  #toggle {

    width: 100px;

    height: 100px;

    background: #ccc;

  }

  </style>

  <script src="//code.jquery.com/jquery-1.10.2.js"></script>

  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

</head>

<body>

 

<p>点击任意地方进行尺寸调整。</p>

<div id="toggle"></div>

 

<script>

$( document ).click(function() {

  $( "#toggle" ).effect( "size", {

    to: { width: 200, height: 60 }

  }, 1000 );

});

</script>

 

</body>

</html>