当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


JQuery UI Scale效果用法及代码示例

Scale Effect

说明:按百分比因子缩小或扩大元素。

  • scale
    • direction(默认:"both")
      类型:String
      效果的方向。可能的值:"both""vertical""horizontal"
    • origin(默认:[ "middle", "center" ])
      类型:Array
      消失点。
    • percent
      类型:Number
      要缩放到的百分比。
    • scale(默认:"both")
      类型:String
      元素的哪些区域将调整大小:"both""box""content"。 Box 调整元素的边框和内边距; content 调整元素内任何内容的大小。

例子:

使用缩放效果切换 div。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>scale 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 toggle the box.</p>
<div id="toggle"></div>
 
<script>
$( document ).click(function() {
  $( "#toggle" ).toggle( "scale" );
});
</script>
 
</body>
</html>

演示:

仅在一个方向上使用缩放效果切换 div。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>scale 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 toggle the box.</p>
<div id="toggle"></div>
 
<script>
$( document ).click(function() {
  $( "#toggle" ).toggle({ effect: "scale", direction: "horizontal" });
});
</script>
 
</body>
</html>

演示:

相关用法


注:本文由纯净天空筛选整理自jqueryui.com大神的英文原创作品 Scale效果。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。