那些大方舍得为你花钱的人,并不是多么富有,谁的钱都不是大风刮来的,而是他觉得你们的关系比钱重要,因为重要才舍得。透过云端的道路,只亲吻攀登者的足迹。
本文实例讲述了jQuery实现的两种简单弹窗效果。分享给大家供大家参考,具体如下:
这里利用jquery实现两种弹窗效果:
1. 淡入弹窗效果:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>www.haodaima.com jQuery弹窗</title>
<style>
*{padding: 0;margin: 0;}
.box{width: 100%;height: 100%;}
.main{width: 100%;height: 100%;background-color: rgba(0,0,0,0.8);display: none;position: fixed;z-index: 1;}
.mainbox{width: 800px;height: 100%;margin: 0 auto;background-color: rgba(255,255,255,0.8);padding: 20px;}
.kkk{width: 100%;height: 1200px;background-color: red;}
.close{color: red;cursor: pointer;}
</style>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function(){
$(".btn").click(function(){
$(".main").fadeIn();
});
$(".close").click(function(){
$(".main").fadeOut();
});
});
</script>
</head>
<body>
<div class="main">
<div class="mainbox">
<div class="close">点击关闭</div>
</div>
</div>
<div class="box">
<div class="kkk">
<input class="btn" type="button" value="点击淡入弹窗" />
</div>
</div>
</body>
</html>
运行效果:
2. 滑动弹窗效果:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>www.haodaima.com jQuery弹窗</title>
<style>
*{padding: 0;margin: 0;}
.box{width: 100%;height: 100%;}
.main{width: 100%;height: 100%;background-color: rgba(0,0,0,0.8);display: none;position: fixed;z-index: 1;}
.mainbox{width: 800px;height: 100%;margin: 0 auto;background-color: rgba(255,255,255,0.8);padding: 20px;display: none;}
.kkk{width: 100%;height: 1200px;background-color: red;}
.close{color: red;cursor: pointer;}
</style>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function(){
$(".btn").click(function(){
$(".main").fadeIn();
$(".mainbox").delay(500).slideDown();
});
$(".close").click(function(){
$(".main").fadeOut();
});
});
</script>
</head>
<body>
<div class="main">
<div class="mainbox">
<div class="close">点击关闭</div>
</div>
</div>
<div class="box">
<div class="kkk">
<input class="btn" type="button" value="点击淡入弹窗" />
</div>
</div>
</body>
</html>
运行效果:
希望本文所述对大家jQuery程序设计有所帮助。
到此这篇关于jQuery实现的两种简单弹窗效果示例就介绍到这了。每个人都想和别人不一样,结果是每个人都一样。更多相关jQuery实现的两种简单弹窗效果示例内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!