jQuery UI API - 縮放特效(Scale Effect)
所屬類別
用法
描述:按照某個百分比縮放元素。
scale
| 參數 | 類型 | 描述 | 默認值 |
|---|---|---|---|
| direction | String | 特效的方向。可能的值:"both"、"vertical" 或 "horizontal"。 | "both" |
| origin | Array | 消失點。 | [ "middle", "center" ] |
| percent | Number | 要縮放到的百分比。 | |
| scale | String | 元素的哪個區域將被調整尺寸:"both"、"box"、"content"。當值為 "box" 時,調整元素的邊框(border)和內邊距(padding)的尺寸。當值為 "content" 時,調整元素內的所有內容的尺寸。 | "both" |
實例
實例 1:使用縮放特效(Scale Effect)切換一個 div。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>縮放特效(Scale 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" ).toggle( "scale" );
});
</script>
</body>
</html>
實例 2:
只在一個方向上使用縮放特效(Scale Effect)切換一個 div。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>>縮放特效(Scale 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" ).toggle({ effect: "scale", direction: "horizontal" });
});
</script>
</body>
</html>
