Copy codeThe Code is as follows:
<! 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>
<Title> </title>
<Script type = "text/javascript">
Function showLogin (){
Var loginDiv = document. getElementById ("loginDiv ");
Var zhezhao = document. getElementById ("zhezhao ");
Var clientx = document.doc umentElement. clientWidth;
Var clienty = document.doc umentElement. clientHeight;
Var l_margin = (clientx-parseInt (loginDiv. style. width)/2;
Var t_margin = (clienty-parseInt (loginDiv. style. height)-200)/2
LoginDiv. style. left = l_margin + "px ";
LoginDiv. style. top = t_margin + "px ";
LoginDiv. style. display = "block ";
Zhezhao. style. display = "block ";
}
Function hidLogin (){
Var loginDiv = document. getElementById ("loginDiv ");
Var zhezhao = document. getElementById ("zhezhao ");
LoginDiv. style. display = "none ";
Zhezhao. style. display = "none ";
}
Function titleMove (){
Var moveable = true;
Var loginDiv = document. getElementById ("loginDiv ");
// Set var clientX = window. event. clientX in advance in the following variables;
Var clientY = window. event. clientY;
Var moveTop = parseInt (loginDiv. style. top );
Var moveLeft = parseInt (loginDiv. style. left );
Document. onmousemove = function MouseMove (){
If (moveable ){
Var y = moveTop + window. event. clientY-clientY;
Var x = moveLeft + window. event. clientX-clientX;
If (x> 0 & y> 0 ){
LoginDiv. style. top = y + "px ";
LoginDiv. style. left = x + "px ";
}
}
}
Document. onmouseup = function Mouseup (){
Moveable = false;
}
}
</Script>
</Head>
<Body>
<! -- Main start z-index: 0 -->
<Div id = "Main" style = "position: absolute; z-index: 0;">
<A href = "javascript: showLogin ()"> login </a>
</Div>
<! -- Main start z-index: 0 -->
<! -- LoginDiv start: z-index: 2 -->
<Div id = "loginDiv" style = "background-color: white; width: 300px; height: 150px; border: 1px solid blue; z-index: 2; display: none; position: absolute; border-top: none ">
<Div onmousedown = "titleMove ()" id = "login_title" style = "width: 300px; height: 25px; background-color: Blue; border: 1px solid silver; border-left: none; border-right: none ">
<! -- -->
<A href = "javascript: hidLogin ()" style = "float: right; text-decoration: none; color: white; margin-right: 2px; font-size: 20px "> × </a>
</Div>
<Table style = "clear: right; width: 298px; height: 115px; text-align: right; margin-top: 10px;">
<Tr> <td> User name: </td> <input type = "text" style = "width: 180px; "/> </td> </tr>
<Tr> <td> password: </td> <input type = "text" style = "width: 180px; "/> </td> </tr>
<Tr> <td> <br/> </td> </tr>
</Table>
</Div>
<! -- LoginDiv end: z-index: 2 -->
<! -- Zhezhao start: z-index: 1 -->
<Div id = "zhezhao" style = "position: absolute; z-index: 1; width: 100%; height: 100%; background-color: silver; display: none; opacity :. 5; ">
<! -- Zhezhao end -->
</Div>
</Body>
</Html>
[Effect]