为了能正常显示demo,网友需要先去下载layer.js,加载到html中
<!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="layer-v3.0.3/layer/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>
我用css3写了个demo<html>
<head>
<meta charset="utf-8"/>
<title>Loading</title>
<style>
.spinner {
margin: 100px auto
width: 60px
height: 60px
text-align: center
font-size: 10px
}
.spinner >div {
background-color: #67CF22
height: 100%
width: 6px
display: inline-block
-webkit-animation: stretchdelay 1.2s infinite ease-in-out
animation: stretchdelay 1.2s infinite ease-in-out
}
.spinner .rect2 {
-webkit-animation-delay: -1.1s
animation-delay: -1.1s
}
.spinner .rect3 {
-webkit-animation-delay: -1.0s
animation-delay: -1.0s
}
.spinner .rect4 {
-webkit-animation-delay: -0.9s
animation-delay: -0.9s
}
.spinner .rect5 {
-webkit-animation-delay: -0.8s
animation-delay: -0.8s
}
@-webkit-keyframes stretchdelay {
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
20% { -webkit-transform: scaleY(1.0) }
}
@keyframes stretchdelay {
0%, 40%, 100% {
transform: scaleY(0.4)
-webkit-transform: scaleY(0.4)
} 20% {
transform: scaleY(1.0)
-webkit-transform: scaleY(1.0)
}
}
</style>
</head>
<body>
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
</body>
</html>