淡与自定义动画及广告

  1. 淡与自定义动画及广告
    1. jQuery淡入淡出动画
    2. 弹窗广告
    3. 自定义动画

淡与自定义动画及广告

jQuery淡入淡出动画

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery淡入淡出动画</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
width: 300px;
height: 300px;
background: red;
display: none;
}
</style>
<script src="js/jquery-1.12.4.js"></script>
<script>
$(function () {
// 编写jQuery相关代码
$("button").eq(0).click(function () {
$("div").fadeIn(1000, function () {
alert("淡入完毕");
});
});
$("button").eq(1).click(function () {
$("div").fadeOut(1000, function () {
alert("淡出完毕");
});
});
$("button").eq(2).click(function () {
$("div").fadeToggle(1000, function () {
alert("切换完毕");
});
});
$("button").eq(3).click(function () {
$("div").fadeTo(1000, 0.2, function () {
alert("淡入完毕");
})
});
});
</script>
</head>
<body>
<button>淡入</button>
<button>淡出</button>
<button>切换</button>
<button>淡入到</button>
<div></div>
</body>
</html>

弹窗广告

  • 动画队列
    1
    $(".ad").stop().slideDown(1000).fadeOut(1000).fadeIn(1000);
    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
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>弹窗广告</title>
    <style>
    *{
    margin: 0;
    padding: 0;
    }
    .ad{
    position: fixed;
    right: 0;
    bottom: 0;
    display: none;
    }
    .ad>span{
    display: inline-block;
    width: 30px;
    height: 30px;
    position: absolute;
    top: 0;
    right: 0;
    }
    </style>
    <script src="js/jquery-1.12.4.js"></script>
    <script>
    $(function () {
    // 1.监听span的点击事件
    $("span").click(function () {
    $(".ad").remove();
    });

    // 2.执行广告动画
    /*
    $(".ad").slideDown(1000, function () {
    $(".ad").fadeOut(1000, function () {
    $(".ad").fadeIn(1000);
    });
    });
    */
    $(".ad").stop().slideDown(1000).fadeOut(1000).fadeIn(1000);

    });
    </script>
    </head>
    <body>
    <div class="ad">
    <img src="images/ad-pic.png" alt="">
    <span></span>
    </div>
    </body>
    </html>

自定义动画

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery自定义动画</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
width: 100px;
height: 100px;
margin-top: 10px;
background: red;
}
.two{
background: blue;
}
</style>
<script src="js/jquery-1.12.4.js"></script>
<script>
$(function () {
$("button").eq(0).click(function () {
$(".one").animate({
marginLeft: 500
}, 5000, function () {
// alert("自定义动画执行完毕");
});
/*
第一个参数: 接收一个对象, 可以在对象中修改属性
第二个参数: 指定动画时长
第三个参数: 指定动画节奏, 默认就是swing
第四个参数: 动画执行完毕之后的回调函数
*/
$(".two").animate({
marginLeft: 500
}, 5000, "linear", function () {
// alert("自定义动画执行完毕");
});
})
$("button").eq(1).click(function () {
$(".one").animate({
width: "+=100"
}, 1000, function () {
alert("自定义动画执行完毕");
});
});
$("button").eq(2).click(function () {
$(".one").animate({
// width: "hide"
width: "toggle"
}, 1000, function () {
alert("自定义动画执行完毕");
});
})
});
</script>
</head>
<body>
<button>操作属性</button>
<button>累加属性</button>
<button>关键字</button>
<div class="one"></div>
<div class="two"></div>
</body>
</html>

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 2113132982@qq.com

文章标题:淡与自定义动画及广告

文章字数:729

本文作者:南邮石磊

发布时间:2020-07-24, 00:43:19

最后更新:2020-08-06, 00:35:28

原始链接:https://southpost.github.io/2020/07/24/%E6%B7%A1%E4%B8%8E%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8A%A8%E7%94%BB%E5%8F%8A%E5%B9%BF%E5%91%8A/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏