国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

javascript彈出窗口實現代碼

2024-05-06 16:25:00
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了javascript彈出窗口實現代碼,非常人性化的設計,點擊頁面可以彈出窗口,感興趣的小伙伴們可以參考一下

很多網頁都實現了彈出窗口,使用方面,特別的人性化,本文就大家介紹javascript實現彈出窗口特效,具體代碼如下:

 

 
  1. <!DOCTYPE html> 
  2. <html> 
  3. <head lang="en"
  4. <meta charset="UTF-8"
  5. <title>彈出窗口</title> 
  6. <script src="js/jquery-1.11.1.js"></script> 
  7. <style> 
  8. *{ 
  9. margin: 0; 
  10. padding: 0; 
  11. div{ 
  12. margin: 0 auto; 
  13. /*border: 1px solid red;*/ 
  14. .overBg{ 
  15. width: 100%; 
  16. height: 100%; 
  17. background: gray; 
  18. opacity: 0.5; 
  19. filter: alpha(opacity=50); 
  20. position: fixed; 
  21. top:0; 
  22. z-index: 300; 
  23. .tc-con{ 
  24. width: 200px; 
  25. height: 200px; 
  26. padding: 30px; 
  27. background: blanchedalmond; 
  28. position: fixed; 
  29. top: 0; 
  30. z-index: 1000; 
  31. </style> 
  32. <script> 
  33. $(function(){ 
  34. $('.tc').hide(); 
  35. $('.btn').click(function(){ 
  36. $('.tc').show(); 
  37. }) 
  38. $('.tc').click(function(){ 
  39. $(this).hide(); 
  40. }) 
  41. }) 
  42. </script> 
  43. </head> 
  44. <body> 
  45. <div class="btn">點擊出現</div> 
  46. <div class="tc"
  47. <div class="overBg"></div> 
  48. <div class="tc-con" id="tc-con">22</div> 
  49. <script> 
  50. var a=document.getElementById('tc-con'); 
  51. a.style.left=(document.body.clientWidth/2- a.clientWidth/2)+'px'
  52. a.style.top=(document.documentElement.clientHeight/2- a.clientHeight/2)+'px'
  53. </script> 
  54. </div> 
  55. <div style="height:2000px">22</div> 
  56. </body> 
  57. </html><!DOCTYPE html> 
  58. <html> 
  59. <head lang="en"
  60. <meta charset="UTF-8"
  61. <title>彈出窗口</title> 
  62. <script src="js/jquery-1.11.1.js"></script> 
  63. <style> 
  64. *{ 
  65. margin: 0; 
  66. padding: 0; 
  67. div{ 
  68. margin: 0 auto; 
  69. /*border: 1px solid red;*/ 
  70. .overBg{ 
  71. width: 100%; 
  72. height: 100%; 
  73. background: gray; 
  74. opacity: 0.5; 
  75. filter: alpha(opacity=50); 
  76. position: fixed; 
  77. top:0; 
  78. z-index: 300; 
  79. .tc-con{ 
  80. width: 200px; 
  81. height: 200px; 
  82. padding: 30px; 
  83. background: blanchedalmond; 
  84. position: fixed; 
  85. top: 0; 
  86. z-index: 1000; 
  87. </style> 
  88. <script> 
  89. $(function(){ 
  90. $('.tc').hide(); 
  91. $('.btn').click(function(){ 
  92. $('.tc').show(); 
  93. }) 
  94. $('.tc').click(function(){ 
  95. $(this).hide(); 
  96. }) 
  97. }) 
  98. </script> 
  99. </head> 
  100. <body> 
  101. <div class="btn">點擊出現</div> 
  102. <div class="tc"
  103. <div class="overBg"></div> 
  104. <div class="tc-con" id="tc-con">22</div> 
  105. <script> 
  106. var a=document.getElementById('tc-con'); 
  107. a.style.left=(document.body.clientWidth/2- a.clientWidth/2)+'px'
  108. a.style.top=(document.documentElement.clientHeight/2- a.clientHeight/2)+'px'
  109. </script> 
  110. </div> 
  111. <div style="height:2000px">22</div> 
  112. </body> 
  113. </html> 

效果圖:

javascript彈出窗口實現代碼

以上就是為大家分享的javascript彈出窗口實現代碼,希望對大家的學習有所幫助。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 晋州市| 井陉县| 宣威市| 宿州市| 双峰县| 额济纳旗| 遂昌县| 鄱阳县| 陆河县| 德庆县| 蓬安县| 额敏县| 吴川市| 微山县| 清水河县| 新竹县| 长葛市| 祁连县| 田林县| 尉犁县| 临湘市| 安仁县| 台江县| 黄山市| 信宜市| 永胜县| 自治县| 呼和浩特市| 日喀则市| 安泽县| 台北市| 高陵县| 五河县| 新巴尔虎左旗| 钟祥市| 乳源| 聂荣县| 河间市| 浮梁县| 兴山县| 新巴尔虎右旗|