• jQuery弹出遮罩层效果完整示例


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jQuery 遮罩层</title>
    <style type="text/css">
    /* 半透明的遮罩层 */
    #overlay {
      background: #000;
      filter: alpha(opacity=50); /* IE的透明度 */
      opacity: 0.5; /* 透明度 */
      display: none;
      position: absolute;
      top: 0px;
      left: 0px;
       100%;
      height: 100%;
      z-index: 100; /* 此处的图层要大于页面 */
      display:none;
      _ padding: 0px 0px 0px 5px; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-left: 3px solid rgb(108, 226, 108); line-height: 20px; 640px; clear: both; border-radius: 0px !important; border-top: 0px !important; border-right: 0px !important; border-bottom: 0px !important; border-image: initial !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; min-height: auto !important; color: gray !important;">#a0a0a0; /* 解决IE6的不透明问题 */
    }
    </style>
    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
    /* 显示遮罩层 */
    function showOverlay() {
      $("#overlay").height(document.body.scrollHeight);
      $("#overlay").width(document.body.scrollWidth);
      // fadeTo第一个参数为速度,第二个为透明度
      // 多重方式控制透明度,保证兼容性,但也带来修改麻烦的问题
      $("#overlay").fadeTo(200, 0.5);
      // 解决窗口缩小时放大后不全屏遮罩的问题
      // 简单来说,就是窗口重置的问题
      $(window).resize(function(){
        $("#overlay").height(document.body.scrollHeight);
        $("#overlay").width(document.body.scrollWidth);
      });
    }
    /* 隐藏覆盖层 */
    function hideOverlay() {
      $("#overlay").fadeOut(200);
    }
    </script>
    </head>
    <body>
    <button onClick="showOverlay();" style=" 100px; height:60px; margin:40px auto 40px auto; display:block;">打开遮罩层</button>
    <button onClick="hideOverlay();" style=" 100px; height:60px; z-index:101; display:block; position:absolute; left:10px; top:10px;">关闭遮罩层</button>
    <h3 align="center"><a href="http://www.jb51.net/">阅谁问君诵,水落清香浮。</a></h3>
    <div style="height:10000px;"></div>
    <div id="overlay"></div>
    </body>
    </html>
  • 相关阅读:
    ●BZOJ 2752 [HAOI2012]高速公路(road)
    ●UVA 11021 tunnello
    ●POJ 2794 Double Patience
    【51Nod1555】布丁怪
    【LG1600】[NOIP2016]天天爱跑步
    【LG5171】Earthquake
    【LG4437】[HNOI/AHOI2018]排列
    【CF1097F】Alex and a TV Show
    【51Nod 1769】Clarke and math2
    【LG5330】[SNOI2019]数论
  • 原文地址:https://www.cnblogs.com/sjqq/p/6361493.html
Copyright © 2020-2023  润新知