温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

jquery弹出层,并且遮罩透明,随页面滚动

发布时间:2020-06-22 16:58:21 来源:网络 阅读:5923 作者:lai坚 栏目:web开发

 

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  5. <title>无标题文档</title> 
  6. <style type="text/css"> 
  7. body {  
  8. font-family:Arial, Helvetica, sans-serif;  
  9. font-size:12px;  
  10. margin:0;  
  11. }  
  12. #main {  
  13. height:1800px;  
  14. padding-top:90px;  
  15. text-align:center;  
  16. }  
  17. #fullbg {  
  18. background-color:Gray;  
  19. left:0px;  
  20. opacity:0.5;  
  21. position:absolute;  
  22. top:0px;  
  23. z-index:3;  
  24. filter:alpha(opacity=50); /* IE6 */  
  25. -moz-opacity:0.5; /* Mozilla */  
  26. -khtml-opacity:0.5; /* Safari */  
  27. }  
  28. #dialog {  
  29. background-color:#FFF;  
  30. border:1px solid #888;  
  31. display:none;  
  32. height:200px;  
  33. left:50%;  
  34. margin:-100px 0 0 -100px;  
  35. padding:12px;  
  36. position:fixed !important; /* 浮动对话框 */  
  37. position:absolute;  
  38. top:50%;  
  39. width:200px;  
  40. z-index:5;  
  41. }#dialog p {margin:0 0 12px;    
  42. }    
  43. #dialog p.close {  
  44. text-align:right;  
  45. }  
  46. </style> 
  47. <body> 
  48. <div id="main"> 
  49. <a href="#" onclick="showBg();">点击这里看 jQuery 遮罩层效果.</a>   
  50. </div> 
  51.  
  52.  
  53. <!-- jQuery 遮罩层 --> 
  54. <div id="fullbg"></div> 
  55. <!-- end jQuery 遮罩层 --> 
  56.  
  57.  
  58. <!-- 对话框 --> 
  59. <div id="dialog"> 
  60. <p class="close"><a href="#" onclick="closeBg();">关闭</a></p> 
  61. <p>正在加载,请稍后...</p>    
  62. </div>    
  63.  
  64. <!-- jQuery 遮罩层上方的对话框 -->   
  65.  
  66. </body> 
  67. </html> 
  68.  
  69.  
  70.  
  71. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
  72. <script type="text/javascript"> 
  73. //显示灰色 jQuery 遮罩层  
  74. function showBg() {  
  75. var bh = $("body").height();  
  76. var bw = $("body").width();  
  77. $("#fullbg").css({  
  78. height:bh,  
  79. width:bw,  
  80. display:"block"  
  81. });  
  82. $("#dialog").show();  
  83. }  
  84. //关闭灰色 jQuery 遮罩  
  85. function closeBg() {  
  86. $("#fullbg,#dialog").hide();  
  87. }  
  88. </script>    
  89.  
  90. <!--[if lte IE 6]> 
  91. <script type="text/javascript"> 
  92. // 浮动对话框   
  93. $(document).ready(function() {  
  94. var domThis = $('#dialog')[0];  
  95. var wh = $(window).height() / 2;  
  96. $("body").css({  
  97. "background-p_w_picpath": "url(about:blank)",  
  98. "background-p_w_upload": "fixed"  
  99. });  
  100. domThis.style.setExpression('top', 'eval((document.documentElement).scrollTop + ' + wh + ') + "px"');  
  101. });  
  102. </script> 
  103. <![endif]-->   
  104.  

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI