>  기사  >  웹 프론트엔드  >  js+div+css 模拟弹出对话框_html/css_WEB-ITnose

js+div+css 模拟弹出对话框_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 12:29:191391검색

今天闲着,做了这么一个网页,在IE5.5-8,ff下测试通过,共享给大家.






弹出模态对话框测试[IE6下测试通过] title >


    .hideDlg
     {
        height : 129px ; width : 368px ;
        display : none ;
     }
    .showDlg
     {
        background-color : #ffffdd ;
        border-width : 3px ;
        border-style : solid ;
        height : 129px ; width : 368px ;
        position :  absolute ;  
        display : block ;
        z-index : 5 ;
     }
    .showDeck  {
        display : block ;
        top : 0px ;
        left : 0px ;
        margin : 0px ;
        padding : 0px ;
        width : 100% ;
        height : 100% ;
        position : absolute ;
        z-index : 3 ;
        background : #cccccc ;
     }
    .hideDeck 
     {
        display : none ;
     }
style >


     function  showDlg()
    {
         // 显示遮盖的层
         var  objDeck  =  document.getElementById( " deck " );
         if ( ! objDeck)
        {
            objDeck  =  document.createElement( " div " );
            objDeck.id = " deck " ;
            document.body.appendChild(objDeck);
        }
        objDeck.className = " showDeck " ;
        objDeck.style.filter = " alpha(opacity=50) " ;
        objDeck.style.opacity = 40 / 100;
        objDeck.style.MozOpacity = 40 / 100;
         // 显示遮盖的层end
        
         // 禁用select
        hideOrShowSelect( true );
        
         // 改变样式
        document.getElementById( ' divBox ' ).className = ' showDlg ' ;
        
         // 调整位置至居中
        adjustLocation();
        
    }
    
     function  cancel()
    {
        document.getElementById( ' divBox ' ).className = ' hideDlg ' ;
        document.getElementById( " deck " ).className = " hideDeck " ;
        hideOrShowSelect( false );
    }
    
     function  hideOrShowSelect(v)
    {
         var  allselect  =  document.getElementsByTagName( " select " );
         for  ( var  i = 0 ; i         {
             // allselect[i].style.visibility = (v==true)?"hidden":"visible";
            allselect[i].disabled  = (v == true ) ? " disabled " : "" ;
        }
    }
    
     function  adjustLocation()
    {
         var  obox = document.getElementById( ' divBox ' );
         if  (obox  != null   &&  obox.style.display  != " none " )
        {
             var  w = 368 ;
             var  h = 129 ;
             var  oLeft,oTop;
            
             if  (window.innerWidth)
            {
                oLeft = window.pageXOffset + (window.innerWidth - w) / 2 +"px";
                oTop = window.pageYOffset + (window.innerHeight - h) / 2 +"px";
            }
             else
            {
                 var  dde = document.documentElement;
                oLeft = dde.scrollLeft + (dde.offsetWidth - w) / 2 +"px";
                oTop = dde.scrollTop + (dde.offsetHeight - h) / 2 +"px";
            }
            
            obox.style.left = oLeft;
            obox.style.top = oTop;
        }
    }
    
script >

head >


    
     百度 a >
    
         1 option >
         2 option >
     select >
    
    
            
                    
                         请输入用户名及密码 td >
                     tr >
                    
                         用户名 td >
                        
                            
                         td >
                         td >
                     tr >
                    
                         密码 td >
                        
                             td >
                         td >
                     tr >
                    
                         td >
                        
                               
                            
                             td >
                           td >
                     tr >
             table >
     div >

body >
html >

 

 

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.