如何给html页面添加动态等待效果

html-css034

如何给html页面添加动态等待效果,第1张

网友看看是否符合需求,修改起来也很方便,都做了注释;

实在不会的,去查看手册即可

<!DOCTYPE HTML>

<html>

<meta charset="UTF-8" />

<head>

<title></title>

</head>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<script src="https://cdn.bootcss.com/layer/3.0.1/layer.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

$(function() {

$('.btn').click(function() {

layer.msg('加载中(点击关闭)', {

anim: 4, //动画效果

icon: 16,

shade: 0.5, //遮罩层透明度

shadeClose: true, //点击遮罩层关闭

time: 0, //不自动关闭

}, function() {

layer.alert('显示加载信息后,你可以执行别的操作,就像这样', {

skin: 'layui-layer-lan',

closeBtn: 0,

anim: 6 //动画类型

})

})

})

})

</script>

<style type="text/css">

html,

body {

margin: 0

padding: 0

}

.demo {}

</style>

<body>

<div class="demo">

<button class="btn">点击显示效果</button>

</div>

</body>

</html>

经查询以及和使用过的人交流可以知道,应该这样进行设置,animation-delay 属性定义动画什么时候开始。

animation-delay 值单位可以是秒(s)或毫秒(ms)。

提示: 允许负值,-2s 使动画马上开始,但跳过 2 秒进入动画。

语法

animation-delay: time

time可选。定义动画开始前等待的时间,以秒或毫秒计。默认值为0

1、@keyframes规则。from{属性:值}  to{属性:值}。

2、0%{属性:值} 100%{属性:值}0% 是动画的开始,100% 是动画的完成。可以在二者之间加入25%,50%等。

3、将动画绑定到选择器:在样式中,设置动画属性animation,自定义动画名称和时长。

4、规定动画开始时的等待时间:animation-delay:时间;可以为秒、毫秒2s,2ms。

5、播放次数:animation-iteration-count:次数;永久播放的值取infinite。

6、动画速度曲线:animation-timing-function:变化类型;变化类型有:linear 匀速;ease-in 开始慢;ease-out 结束慢;ease 动画有一个缓慢的开始,然后快,结束慢。

扩展资料

animation 属性是一个简写属性,用于设置六个动画属性:

1、animation-name

规定需要绑定到选择器的 keyframe 名称。

2、animation-duration

规定完成动画所花费的时间,以秒或毫秒计。

3、animation-timing-function

规定动画的速度曲线。

4、animation-delay

规定在动画开始之前的延迟。

5、animation-iteration-count

规定动画应该播放的次数。

6、animation-direction

规定是否应该轮流反向播放动画。

注释:请始终规定 animation-duration 属性,否则时长为 0,就不会播放动画了。