web前端----jQuery动画效果

动画效果

// 基本
show([s,[e],[fn]])
hide([s,[e],[fn]])
toggle([s],[e],[fn])
// 滑动
slideDown([s],[e],[fn])
slideUp([s,[e],[fn]])
slideToggle([s],[e],[fn])
// 淡入淡出
fadeIn([s],[e],[fn])
fadeOut([s],[e],[fn])
fadeTo([[s],o,[e],[fn]])
fadeToggle([s,[e],[fn]])
// 自定义(了解即可)
animate(p,[s],[e],[fn])

自定义动画示例:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="x-ua-compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>点赞动画示例</title>
  <style>
    div {
      position: relative;
      display: inline-block;
    }
    div>i {
      display: inline-block;
      color: red;
      position: absolute;
      right: -16px;
      top: -5px;
      opacity: 1;
    }
  </style>
</head>
<body>

<div id="d1">点赞</div>
<script src="jquery-3.2.1.min.js"></script>
<script>
  $("#d1").on("click", function () {
    var newI = document.createElement("i");
    newI.innerText = "+1";
    $(this).append(newI);
    $(this).children("i").animate({
      opacity: 0
    }, 1000)
  })
</script>
</body>
</html>
点赞特效简单示例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动画</title>
    <style>
        .hide{
            display: none;
        }
    </style>
</head>
<body>
<img src="z.png" alt="">
<script src="jquery-3.2.1.min.js"></script>
<button class="c1">召唤</button>
<button class="c2">淡出</button>
<button class="c3">淡入</button>
<button class="c4">淡出到0.66透明度</button>
<button class="c5">淡入淡出</button>
<button class="c6">动画:图片变小</button>
<script>
    $(".c1").on("click",function () {
//        $("img").hide();
//        $("img").show();
        $("img").toggle();
    });

//    淡出
    $(".c2").on("click",function () {
        $("img").fadeOut();
        $("img").fadeOut("fast"); //快速的淡出
    });
//    淡入
    $(".c3").on("click",function () {
//        增加淡入的时间
        $("img").fadeIn(3000,function () {
//            alert(123)
        });
    });
//    淡出到0.66透明度
    $(".c4").on("click",function () {
        $("img").fadeTo(3000,0.66,function () {
//            alert(123)
        })
    });
//    淡入淡出
    $(".c5").on("click",function () {
        $("img").fadeToggle(3000,function () {
//            alert(123)
        })
    })
//    动画-图片变小
    $(".c6").on("click",function () {
        $("img").animate(
            {
                width:"80px",
                height:"80px"
            },3000,function () {
                //这是一个回调函数
                alert(123)
            }
        )
    })
</script>
</body>
</html>
动画效果
posted @ 2018-03-18 21:27  TheLand  阅读(232)  评论(0编辑  收藏  举报