javascript彈出窗口實(shí)現(xiàn)代碼
很多網(wǎng)頁(yè)都實(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)文章
js將鍵值對(duì)字符串轉(zhuǎn)為json字符串的方法
下面小編就為大家分享一篇js將鍵值對(duì)字符串轉(zhuǎn)為json字符串的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-03-03JavaScript中使用構(gòu)造器創(chuàng)建對(duì)象無(wú)需new的情況說(shuō)明
JS中創(chuàng)建對(duì)象可以直接使用直接量的方式,這里討論的是定義一個(gè)構(gòu)造器(function)的情況2012-03-03Bootstrap table 服務(wù)器端分頁(yè)功能實(shí)現(xiàn)方法示例
這篇文章主要介紹了Bootstrap table 服務(wù)器端分頁(yè)功能實(shí)現(xiàn)方法,結(jié)合實(shí)例形式詳細(xì)分析了Bootstrap table 服務(wù)器端后臺(tái)交互與分頁(yè)功能相關(guān)操作技巧,需要的朋友可以參考下2020-06-06layer.alert回調(diào)函數(shù)執(zhí)行關(guān)閉彈窗的實(shí)例
今天小編就為大家分享一篇layer.alert回調(diào)函數(shù)執(zhí)行關(guān)閉彈窗的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09javascript 通過(guò)鍵名獲取鍵盤(pán)的keyCode方法
下面小編就為大家分享一篇javascript 通過(guò)鍵名獲取鍵盤(pán)的keyCode方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-12-12