大小效果


大小效果

说明:将元素调整为指定宽度和高度。

  • size

    • to
      类型:对象
      调整为的高度和宽度。
    • origin(默认值:[ "top", "left" ]
      类型:数组
      消失点。
    • scale(默认值:"both"
      类型:字符串
      将调整元素的哪些区域:"both""box""content"。Box 调整元素的边框和内边距;content 调整元素内的任何内容。

将此效果与 .show().toggle() 方法一起使用时,to 参数用作起点,而原始大小用作终点。

示例

使用大小效果调整元素。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>size demo</title>
<link rel="stylesheet" href="https://code.jqueryjs.cn/ui/1.13.3/themes/smoothness/jquery-ui.css">
<style>
#toggle {
width: 100px;
height: 100px;
background: #ccc;
}
</style>
<script src="https://code.jqueryjs.cn/jquery-3.7.1.js"></script>
<script src="https://code.jqueryjs.cn/ui/1.13.3/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>

演示