javascript彈出窗口實(shí)現(xiàn)代碼
更新時(shí)間:2015年11月12日 09:02:28 作者:浮世微涼
這篇文章主要介紹了javascript彈出窗口實(shí)現(xiàn)代碼,非常人性化的設(shè)計(jì),點(diǎn)擊頁面可以彈出窗口,感興趣的小伙伴們可以參考一下
很多網(wǎng)頁都實(shí)現(xiàn)了彈出窗口,使用方面,特別的人性化,本文就大家介紹javascript實(shí)現(xiàn)彈出窗口特效,具體代碼如下:
<!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">點(diǎn)擊出現(xiàn)</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">點(diǎn)擊出現(xiàn)</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彈出窗口實(shí)現(xiàn)代碼,希望對(duì)大家的學(xué)習(xí)有所幫助。
相關(guān)文章
JavaScript常用進(jìn)制轉(zhuǎn)換及位運(yùn)算實(shí)例解析
這篇文章主要介紹了JavaScript常用進(jìn)制轉(zhuǎn)換及位運(yùn)算實(shí)例解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-10-10
Grid得到選擇行數(shù)據(jù)的方法總結(jié)
Grid得到選擇行數(shù)據(jù)的方法總結(jié),需要的朋友可以參考下。2011-01-01
js正文內(nèi)容高亮效果的實(shí)現(xiàn)方法
這篇文章介紹了js正文內(nèi)容高亮效果的實(shí)現(xiàn)方法,有需要的朋友可以參考一下2013-06-06
JS 根據(jù)子網(wǎng)掩碼,網(wǎng)關(guān)計(jì)算出所有IP地址范圍示例
這篇文章主要介紹了JS 根據(jù)子網(wǎng)掩碼,網(wǎng)關(guān)計(jì)算出所有IP地址范圍,涉及IP地址、子網(wǎng)的正則驗(yàn)證,子網(wǎng)掩碼計(jì)算等相關(guān)操作技巧,需要的朋友可以參考下2016-09-09

