一个绝对居中的例子,大家参考一下吧
<!doctype html> <head> <meta charset="UTF-8"> <title>绝对居中实例</title> <style type="text/css"> .box{220px;height:100px;border:1px solid red;padding:20px 0 0 20px; position:absolute; left:50%; top:50%; margin-left:-110px; margin-top:-50px; } </style> </head> <body> <div class="box"> <form action="" method="post"> 账号:<input type="text" name="useername"/><br/> 密码:<input type="password" name="password"/><br/> <input type="submit" value="登录"/> </form> </div> </body> </html>