用HTML写一个登录框

html-css011

用HTML写一个登录框,第1张

<!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=utf-8" />

<link rel="stylesheet" type="text/css" href="css/xing.css" />

  </head>  

  <body>  

  <div id="content" style="margin:0 auto background-color:#0F6 width:1000px height:500px position:relative">

  <div class="login" style="position:absolute top:50%left:50%margin-top:-100pxmargin-left:-200pxbackground:#69F width:400px height: 200px border-radius:10px">

      <div style=" margin-left:100pxmargin-top:50px">

        <p style="display:inline">用户名:</p>

            <input type="text" value="123"/>

      </div>

      <div style="margin-left:100pxmargin-top:20px">

        <p style="display:inline">密&nbsp码:</p>

            <input type="password" value="123"/>

      </div>

      <div style=" text-align:centermargin-top:20px">

        <input class="button" type="button" value="登录" style="margin-right:10px padding:5px 15px background:#F9C border-radius:3px border:#F0C 1px solid"/>

            <input class="button" type="button" value="重置" style="padding:5px 15px background:#F9C border-radius:3px border:#F0C 1px solid"/>

      </div>

     </div>

    </div>    

  </body>  

</html> 

整体居中,效果还可以。

div id=win style="display:nonePOSITION:absoluteleft:50%top:50%width:600pxheight:400pxmargin-left:-300pxmargin-top:-200pxborder:1px solid #888background-color:#edftext-align:center">这是DIV登录框示例<br><a href="javascript:closeLogin()">关闭登录框</a></div>

<script>

function openLogin(){

document.getElementById("win").style.display=""

}

function closeLogin(){

document.getElementById("win").style.display="none"

}

</script>

<a href="javascript:openLogin()">打开登录框</a>