zoukankan      html  css  js  c++  java
  • jQuery动画

    jQuery animate() 方法允许您创建自定义的动画。

    $(selector).animate({params},speed,callback);

    必需的 params 参数定义形成动画的 CSS 属性(以json的键值对形式)。

    可选的 speed 参数规定效果的时长。它可以取以下值:"slow"、"fast" 或毫秒。

    可选的 callback 参数是动画完成后所执行的函数名称。

    jQuery animate() - 操作单个属性

    栗子①

    $("button").click(function(){
      $("div").animate({left:'250px'});
    }); 

    jQuery animate() - 操作多个属性

    栗子②

    $("button").click(function(){
      $("div").animate({
        left:'250px',
        opacity:'0.5',
        height:'150px',
        '150px'
      });
    }); 

    可以用 animate() 方法来操作所有 CSS 属性吗?

    几乎可以!不过,需要记住一件重要的事情:当使用 animate() 时,必须使用 Camel 标记法书写所有的属性名,比如,必须使用 paddingLeft 而不是 padding-left,使用 marginRight 而不是 margin-right,等等。

    同时,色彩动画并不包含在核心 jQuery 库中。如果需要生成颜色动画,您需要从 jquery.com 下载 Color Animations 插件。

    jQuery animate() - 使用相对值

    也可以定义相对值(该值相对于元素的当前值)。需要在值的前面加上 += 或 -=:

    栗子③

    $("button").click(function(){
      $("div").animate({
        left:'250px',
        height:'+=150px',
        '+=150px'
      });
    }); 

    jQuery animate() - 使用预定义的值

    您甚至可以把属性的动画值设置为 "show"、"hide" 或 "toggle":

    $("button").click(function(){
      $("div").animate({
        height:'toggle'
      });
    }); 

    jQuery animate() - 使用队列功能

    编写多个 animate() 调用,jQuery 会创建包含这些方法调用的"内部"队列。然后逐一运行这些 animate 调用。

    $("button").click(function(){
      var div=$("div");
      div.animate({height:'300px',opacity:'0.4'},"slow");
      div.animate({'300px',opacity:'0.8'},"slow");
      div.animate({height:'100px',opacity:'0.4'},"slow");
      div.animate({'100px',opacity:'0.8'},"slow");
    }); 

       此文章基本摘自jQuery菜鸟自学~~~

    什么是成功?就是所有失败的路都走过了,只剩下一条路还没有走,这条路就叫成功!
  • 相关阅读:
    60阶单群同构于A5的证明
    Riemann映射定理
    一个特殊情形的Mittag-Leffler分解
    一个重要的函数
    指数有限的子群存在一个右陪集代表元系,同时也是左陪集代表元系
    素数的平方阶群必为Abel群
    $mathscr{F}$类
    一个多项式问题
    Mittag-Leffler定理,Weierstrass因子分解定理和插值定理
    C -Concatenating Teams (字符串hash)
  • 原文地址:https://www.cnblogs.com/yuqingfamily/p/5769452.html
Copyright © 2011-2022 走看看