div实现遮罩层效果( div弹出层,后面变色不可编辑转)

北战南征 提交于 2019-11-27 04:17:05

转自:http://forlab.iteye.com/blog/1767843

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <title>Jquery遮罩层</title>
  
  <style type="text/css">      
      #BgDiv{background-color:#e3e3e3; position:absolute; z-index:99; left:0; top:0; display:none; width:100%; height:100%;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}
      
      #DialogDiv{position:absolute;width:400px; left:50%; top:50%; margin-left:-200px; height:auto; z-index:100;background-color:#fff; border:1px #8FA4F5 solid; padding:1px;}
      #DialogDiv h2{ height:25px; font-size:14px; background-color:#8FA4F5; position:relative; padding-left:10px; line-height:25px;}
      #DialogDiv h2 a{position:absolute; right:5px; font-size:12px; color:#000000}
      #DialogDiv .form{padding:10px;}

  </style>
  
  <script language="javascript" type="text/javascript" src="jquery-1.4.2.min.js"></script>
  <script language="javascript" type="text/javascript">
   function ShowDIV(thisObjID) {
          $("#BgDiv").css({ display: "block", height: $(document).height() });
          $("#" + thisObjID ).css("top", "100px");
          $("#" + thisObjID ).css("display", "block");
   }

  function closeDiv(thisObjID) {
      $("#BgDiv").css("display", "none");
      $("#" + thisObjID).css("display", "none");
  }
 </script>
  
 </head>
 
 <body>
 <div>
   
  <input value="forlab" type="button" id="btnShow1" onclick="alert('forlab')" />
  <div id="BgDiv"></div>
  
  <!--遮罩层显示的DIV1-->
  <div id="DialogDiv" style="display:none">
    <h2>弹出层<a href="#" id="btnClose" onclick="javascript:closeDiv('DialogDiv')">关闭</a></h2>
   <div class="form">我是弹出对话框forlab!</div>
  </div>
  
  
  <p>
   <input value="弹出遮罩层1" type="button" id="btnShow1" onclick="ShowDIV('DialogDiv')" />
  </p>
   <div>
 </body>
</html>
View Code

 

 

转载于:https://www.cnblogs.com/summer520/p/3386784.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!