javascript弹出窗口实现代码
作者:bea
很多网页都实现了弹出窗口,使用方面,特别的人性化,本文就大家介绍javascript实现弹出窗口特效,具体代码如下: <!DOCTYPE html><html><head lang="en"><meta charset="UTF-8"><title>弹出窗口</title><script src="js/jquery-1.11.1.js"></script><style&
很多网页都实现了弹出窗口,使用方面,特别的人性化,本文就大家介绍javascript实现弹出窗口特效,具体代码如下:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>弹出窗口</title>
<script src="js/jquery-1.11.1.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
div{
margin: 0 auto;
/*border: 1px solid red;*/
}
.overBg{
width: 100%;
height: 100%;
background: gray;
opacity: 0.5;
filter: alpha(opacity=50);
position: fixed;
top:0;
z-index: 300;
}
.tc-con{
width: 200px;
height: 200px;
padding: 30px;
background: blanchedalmond;
position: fixed;
top: 0;
z-index: 1000;
}
</style>
<script>
$(function(){
$('.tc').hide();
$('.btn').click(function(){
$('.tc').show();
})
$('.tc').click(function(){
$(this).hide();
})
})
</script>
</head>
<body>
<div class="btn">点击出现</div>
<div class="tc">
<div class="overBg"></div>
<div class="tc-con" id="tc-con">22</div>
<script>
var a=document.getElementById('tc-con');
a.style.left=(document.body.clientWidth/2- a.clientWidth/2)+'px';
a.style.top=(document.documentElement.clientHeight/2- a.clientHeight/2)+'px';
</script>
</div>
<div style="height:2000px">22</div>
</body>
</html><!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>弹出窗口</title>
<script src="js/jquery-1.11.1.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
div{
margin: 0 auto;
/*border: 1px solid red;*/
}
.overBg{
width: 100%;
height: 100%;
background: gray;
opacity: 0.5;
filter: alpha(opacity=50);
position: fixed;
top:0;
z-index: 300;
}
.tc-con{
width: 200px;
height: 200px;
padding: 30px;
background: blanchedalmond;
position: fixed;
top: 0;
z-index: 1000;
}
</style>
<script>
$(function(){
$('.tc').hide();
$('.btn').click(function(){
$('.tc').show();
})
$('.tc').click(function(){
$(this).hide();
})
})
</script>
</head>
<body>
<div class="btn">点击出现</div>
<div class="tc">
<div class="overBg"></div>
<div class="tc-con" id="tc-con">22</div>
<script>
var a=document.getElementById('tc-con');
a.style.left=(document.body.clientWidth/2- a.clientWidth/2)+'px';
a.style.top=(document.documentElement.clientHeight/2- a.clientHeight/2)+'px';
</script>
</div>
<div style="height:2000px">22</div>
</body>
</html>
效果图:
以上就是为大家分享的javascript弹出窗口实现代码,希望对大家的学习有所帮助。
有用 | 无用
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>弹出窗口</title>
<script src="js/jquery-1.11.1.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
div{
margin: 0 auto;
/*border: 1px solid red;*/
}
.overBg{
width: 100%;
height: 100%;
background: gray;
opacity: 0.5;
filter: alpha(opacity=50);
position: fixed;
top:0;
z-index: 300;
}
.tc-con{
width: 200px;
height: 200px;
padding: 30px;
background: blanchedalmond;
position: fixed;
top: 0;
z-index: 1000;
}
</style>
<script>
$(function(){
$('.tc').hide();
$('.btn').click(function(){
$('.tc').show();
})
$('.tc').click(function(){
$(this).hide();
})
})
</script>
</head>
<body>
<div class="btn">点击出现</div>
<div class="tc">
<div class="overBg"></div>
<div class="tc-con" id="tc-con">22</div>
<script>
var a=document.getElementById('tc-con');
a.style.left=(document.body.clientWidth/2- a.clientWidth/2)+'px';
a.style.top=(document.documentElement.clientHeight/2- a.clientHeight/2)+'px';
</script>
</div>
<div style="height:2000px">22</div>
</body>
</html><!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>弹出窗口</title>
<script src="js/jquery-1.11.1.js"></script>
<style>
*{
margin: 0;
padding: 0;
}
div{
margin: 0 auto;
/*border: 1px solid red;*/
}
.overBg{
width: 100%;
height: 100%;
background: gray;
opacity: 0.5;
filter: alpha(opacity=50);
position: fixed;
top:0;
z-index: 300;
}
.tc-con{
width: 200px;
height: 200px;
padding: 30px;
background: blanchedalmond;
position: fixed;
top: 0;
z-index: 1000;
}
</style>
<script>
$(function(){
$('.tc').hide();
$('.btn').click(function(){
$('.tc').show();
})
$('.tc').click(function(){
$(this).hide();
})
})
</script>
</head>
<body>
<div class="btn">点击出现</div>
<div class="tc">
<div class="overBg"></div>
<div class="tc-con" id="tc-con">22</div>
<script>
var a=document.getElementById('tc-con');
a.style.left=(document.body.clientWidth/2- a.clientWidth/2)+'px';
a.style.top=(document.documentElement.clientHeight/2- a.clientHeight/2)+'px';
</script>
</div>
<div style="height:2000px">22</div>
</body>
</html>
效果图:
以上就是为大家分享的javascript弹出窗口实现代码,希望对大家的学习有所帮助。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jquery动画效果学习笔记(8种效果)
- javascript:void(0)点击登录没反应怎么解决
- javascript:void(0)是什么意思及href=#与href=javascriptvoid(0)的区别
- 每天一篇javascript学习小结(Date对象)
- 有关Promises异步问题详解
- 以jQuery中$.Deferred对象为例讲解promise对象是如何处理异步问题
- Jquery promise实现一张一张加载图片
- jquery转盘抽奖功能实现
- javascript生成随机数方法汇总
- js正则表达式验证邮件地址
- 每天一篇javascript学习小结(Boolean对象)
- 为何JS操作的href都是javascript:void(0);呢
- 基于jquery实现左右按钮点击的图片切换效果
- js图片轮播效果实现代码
- javascript伸缩菜单栏实现代码分享
- javascript发送短信验证码实现代码
- javascript倒计时效果实现
- 基于jquery步骤进度条源码分享
- javascript手风琴下拉菜单实现代码