用 js和css彈出層

來源:互聯網
上載者:User

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>factly彈出層</title>
<style type="text/css">
<!--

.tittleup {
font-size:14px;
font-weight:bold;
color:#000066;
padding-left:25px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #d0daec;
margin-bottom: 10px;
padding-bottom: 10px;
}
.od {
float:right;
font-size:14px;
color: #CC0000;
text-decoration: none;
}
.od:hover {
color:#FF0000;
}
.fd {
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:2px;
margin-left:2px;
float:left;
overflow:hidden;
position:absolute;
left:200px;
top:30px;
z-index: 10;
}
.contentup {
padding:20px;
}
}
-->
</style>
</head>
<body >
<div> <a href="#" onclick = "show('fd',650,300);return false;"> [開啟層] </a> </div>
  <label>
  <select name="select">
    <option>哈哈</option>
    <option>哈哈哈哈</option>
    <option>哈哈哈哈哈哈</option>
    <option>哈哈哈哈哈哈哈哈</option>
    <option>哈哈</option>
    <option>哈哈哈哈</option>
    <option>哈哈哈哈哈哈</option>
    <option>哈哈哈哈哈哈哈哈</option>
    <option>哈哈</option>
    <option>哈哈哈哈</option>
    <option>哈哈哈哈哈哈</option>
    <option>哈哈哈哈哈哈哈哈</option>
  </select>
  </label>
aaaaaa
aaaaa
aaaaa
aaaa
aaaa
aaaaaa
<input name="" type="text">

<label>
<input type="checkbox" name="checkbox2" value="checkbox">
</label>

<div id="fd" class="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="contentup"> <a href="#" class="od" onclick = "closeed('fd');return false;">

  關 閉 </a>
    <div id="tittleup" class="tittleup">factly哈哈</div>
 kwg kwg
   <label>
  <input type="checkbox" name="checkbox" value="checkbox">
  </label>
  <input name="" type="text">
  <input name="" type="text">
  <input name="" type="text">
  <label>aaa
  <select name="select">
    <option>哈哈</option>
    <option>哈哈哈哈</option>
    <option>哈哈哈哈哈哈</option>
    <option>哈哈哈哈哈哈哈哈</option>
    <option>哈哈</option>
    <option>哈哈哈哈</option>
    <option>哈哈哈哈哈哈</option>
    <option>哈哈哈哈哈哈哈哈</option>
    <option>哈哈</option>
    <option>哈哈哈哈</option>
    <option>哈哈哈哈哈哈</option>
    <option>哈哈哈哈哈哈哈哈</option>
  </select>
  </label>
</div>
</div>
<script type="text/javascript">
    var prox;
var proy;
var proxc;
var proyc;
var isIe=(document.all)?true:false;

function setSelectState(state)
{
    var objl=document.getElementsByTagName('select');
    for(var i=0;i<objl.length;i++)
    {
        objl[i].style.visibility=state;
    }
}

//關閉視窗
function closeWindow()
{
    if(document.getElementById('back')!=null)
    {
        document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
    }
    if(document.getElementById('mesWindow')!=null)
    {
        document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
    }
    if(isIe)
    {
        setSelectState('');
    }
}
/*--開啟Div--*/
/*參數說明:id是div的ID、divWidth是彈出層的寬度、divHeight是彈出層的高度*/
function show(id,divWidth,divHeight)
{
    closeWindow();
    var bWidth = parseInt(document.body.scrollWidth);
    var bHeight=parseInt(window.screen.height-document.body.scrollHeight);
    if(isIe)
    {
        setSelectState('');
    }
    var back=document.createElement("div");
    back.id="back";
    var styleStr="top:0px;left:0px;position:absolute;background:#D9D9D9;width:"+bWidth+"px;height:"+bHeight+"px;";
    styleStr+=(isIe)?"filter:alpha(opacity=40);":"opacity:0.40;";
    back.style.cssText=styleStr;
    document.body.appendChild(back);
    var o = document.getElementById(id);
        o.style.display = "block";
        o.style.width = "1px";
        o.style.height = "1px";
        prox = setInterval(function(){openx(o,divWidth,divHeight)},10);
 
}

/*--開啟x--*/
function openx(o,openWidth,openHeight)
{
   
        var cx = parseInt(o.style.width);
        if(cx < openWidth)
        {
            o.style.width = (cx + Math.ceil((openWidth-cx)/1)) +"px";
        }
        else
        {
            clearInterval(prox);
            proy = setInterval(function(){openy(o,openHeight)},10);
        }
    }   
function openy(o,c){/*--開啟y--*/   
   
    var cy = parseInt(o.style.height);
    if(cy < c)
    {
        o.style.height = (cy + Math.ceil((c-cy)/10)) +"px";
    }
    else
    {
        clearInterval(proy);           
    }
}   
 
/*--關閉Div--*/
function closeed(id)
{
 closeWindow();
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);       
    var o = document.getElementById(id);
    if(o.style.display == "block")
    {
        proyc = setInterval(function(){closey(o)},10);           
    }       

/*--關閉y--*/ 
function closey(o)
{   
    var cy = parseInt(o.style.height);
    if(cy > 0)
    {
        o.style.height = (cy - Math.ceil(cy/10)) +"px";
    }
    else
    {
        clearInterval(proyc);               
        proxc = setInterval(function(){closex(o)},10);
    }
}
/*--開啟x--*/  
function closex(o)
{
    clearInterval(proxc);
    o.style.display = "none";
}
</script>

</body>
</html>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.