<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>
整体居中,效果还可以。
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>登录</title>
<link href="css/bootstrap.min.css" rel="stylesheet"></head><body><nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="./">jsp作业</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="login.html">登录</a></li>
</ul>
</div>
</div></nav><div class="container">
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<form class="form-signin" target="submitFrame" method="post">
<h2 class="form-signin-heading">登录到jsp作业</h2>
<label for="inputEmail">Email</label>
<input type="email" id="inputEmail" class="form-control" placeholder="请输入Email" required autofocus><br>
<label for="inputPassword">密码</label>
<input type="password" id="inputPassword" class="form-control" placeholder="请输入密码" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me" checked="checked">记住密码</label>
</div>
<button type="submit" class="btn btn-primary" id="btn-login">登录</button>
<a href="reg.html" class="btn btn-default">注册</a>
</form>
<iframe style="display: none" name="submitFrame" src="about:blank"></iframe>
</div>
<div class="col-md-4">
</div>
</div>
<script src="js/jquery.min.js"></script></body></html>