플로팅 레이어 플라이아웃

3283 단어 JavaScripthtmlcss
<html>
  <head>
    <style type="text/css">
      #tranDiv {
        position:absolute;
        left:0px;
        top:0px;
      }
      #tranDivBack {
        position:absolute;
        left:0px;
        top:0px;
        width:100%;
        height:100%;
        background-color:#000000;
        filter:alpha(Opacity=30);
        -moz-opacity:0.3;
        opacity:0.3;
      }
      #infoDiv {
        position:absolute;
        left:0px;
        top:0px;
        width:100%;
        height:100%;
        text-align:center;
      }
      .pop_box {
        background:#FFF;
        padding:20px;
        border:#666 8px solid;
      }
    </style>
    <script language="javascript"> 
      //     ,         
      //var div_width = 464;
      //var div_height = 445;
      function showWindow(width,height){ 
        location.href="#";
        //width = div_width;
        //height = div_height;
        var windowstr= document.getElementById("popLayer").innerHTML;
        document.getElementById("infoDiv").innerHTML=windowstr; 
        document.getElementById("infoDiv").style.left=((document.body.clientWidth-width)>0?(document.body.clientWidth-width):0)/2+"px"; 
        document.getElementById("infoDiv").style.top=100+"px"; 
        document.getElementById("infoDiv").style.zIndex=10001;
        document.getElementById("infoDiv").style.width=width; 
        document.getElementById("infoDiv").style.height=height; 
        document.getElementById("tranDiv").style.height=document.body.clientHeight+ "px"; 
        document.getElementById("tranDiv").style.width=document.body.clientWidth+ "px"; 
        document.getElementById("tranDiv").style.display=""; 
        document.getElementById("tranDivBack").style.display=""; 
        document.getElementById("tranDivBack").style.zIndex=10000;
        document.getElementById("infoDiv").style.display=""; 
      } 
      function closeWindow(){
        document.getElementById("tranDiv").style.display="none"; 
      } 
    </script>
  </head>
  <!--     -->
  <div id="tranDiv" style="display:none;">
    <div id="tranDivBack"></div>
    <div id="infoDiv"></div>
  </div>
  <!--       -->
  <!--   -->
  <div id="popLayer" style="display:none;">
    <div class="pop_box">
      <img src="test.jpg" width="424" height="405" />
      <button onClick="closeWindow();">  </button>
    </div>
  </div>
  <a href="javascript:showWindow(800,600);">      </a>
</html>

좋은 웹페이지 즐겨찾기