下面是完整结果截图及其效果:
参考代码如下:
<html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
<title>登录注册页</title>
<style>
#all{
width: 1100px;
height: 800px;
background-color: #6CACD8;
margin: auto;
}
#top{
width: 1100px;
height: 100px;
background-color: aquamarine;
margin: auto;
position: absolute;
}
#center{
width: 900px;
height: 600px;
background-color: lightgoldenrodyellow;
position: absolute;
margin-top: 200px;
margin-left: 200px;
}
#right{
width: 200px;
height: 600px;
background-color: aqua;
position: absolute;
margin-top: 200px;
}
#center table{
width: 100%;
height: 500px;
}
#register-form{
display: none; /* 初始状态下隐藏 */
}
#login-form{
display: none; /* 初始状态下隐藏 */
}
#information{
display: none; /* 初始状态下隐藏 */
margin: auto;
}
.cell1{
text-align: right;
padding-right: 20px;
}
.cell2{
width: 220px;
height: 25px;
border: 1px solid grey;
border-radius: 6px;
padding-left: 6px;
}
.cell3{
width: 200px;
height: 40px;
background-color: #6CACD8;
border: 1px solid #6CACD8;
border-radius: 20px;
}
.cell4{
width: 120px;
height: 25px;
border: 1px solid grey;
border-radius: 6px;
padding-left: 6px;
}
.cell5{
width: 180px;
height: 25px;
border: 1px solid grey;
border-radius: 6px;
padding-left: 6px;
}
.cell7{
width: 500px;
height: 25px;
border: 1px solid grey;
border-radius: 6px;
padding-left: 6px;
}
</style>
<title>Title</title>
</head>
<script>
// 定义一个函数,用于显示注册表单
function showRegisterForm() {
// 获取注册表单,并将其显示出来
document.getElementById("register-form").style.display="block";
document.getElementById("login-form").style.display="none";
document.getElementById("information").style.display="none";
}
// 定义一个函数,用于显示注册表单
function showLoginForm() {
// 获取注册表单,并将其显示出来
document.getElementById("login-form").style.display="block";
document.getElementById("register-form").style.display="none";
document.getElementById("information").style.display="none";
}
function showInformation(){
document.getElementById("information").style.display="block";
document.getElementById("register-form").style.display="none";
document.getElementById("login-form").style.display="none";
}
</script>
<body>
<div id="all">
<div id="top">
<button onclick="showRegisterForm()" style="position:absolute;width: 100px;margin-top: 40px;margin-left: 530px">Register</button>
</div>
<button onclick="showLoginForm()" style="position:absolute;width: 100px;margin-top:140px;margin-left: 530px">Login</button>
<div id="right">
<button onclick="showInformation()" style="position:absolute;width:100px;display: block;margin-left: 45px;margin-top: 300px">个人简介</button>
</div>
<div id="center">
<%--表一--%>
<form id="information" style="display: none;">
<table >
<br>
<br>
<caption style="text-align: center"><strong>Information</strong></caption>
<br>
<tr>
<td class="cell1">ID:</td>
<td>
K2
</td>
</tr>
<tr>
<td class="cell1">Password:</td>
<td>
***************
</td>
</tr>
<tr>
<td class="cell1">First Name:</td>
<td>
×
</td>
</tr>
<tr>
<td class="cell1">Last Name:</td>
<td>
××
</td>
</tr>
<tr>
<td class="cell1">Address:</td>
<td>
******
</td>
</tr>
<tr>
<td class="cell1">Country:</td>
<td>
中国
</td>
</tr>
<tr>
<td class="cell1">City:</td>
<td>
广州市
</td>
</tr>
<tr>
<td class="cell1">Email Address:</td>
<td>
**************
</td>
</tr>
<tr>
<td class="cell1">Interest:</td>
<td>
Technology;
Enterprise;
Research;
Government;
People;
Life Style;
Opinion
</td>
</tr>
</table>
</form>
<%-- 表二--%>
<form id="login-form" style="display: none;">
<table>
<br>
<br>
<caption style="text-align: center"><strong>Please Log In</strong></caption>
<tr>
<td class="cell1">Login:</td>
<td>
<input class="cell7" type="text" placeholder="请输入Login">
</td>
</tr>
<tr>
<td class="cell1">Password:</td>
<td>
<input class="cell7" type="password" placeholder="请输入password">
</td>
</tr>
<tr>
<td> </td>
<td>
<input class="cell3" type="button" value="OK" style="padding-left: 6px">
<input class="cell3" type="button" value="Forget Password" >
</td>
</tr>
</table>
</form>
<%-- 表三--%>
<form id="register-form" style="display: none;">
<table >
<br>
<caption style="text-align: center"><strong>New Member</strong></caption>
<br>
<tr>
<td class="cell1">ID</td>
<td>
<input class="cell2" type="text" placeholder="请输入ID">
</td>
</tr>
<tr>
<td class="cell1">Password</td>
<td>
<input class="cell2" type="password" placeholder="请输入password">
</td>
</tr>
<tr>
<td class="cell1">Re-Password</td>
<td>
<input class="cell2" type="password" placeholder="请再次输入password">
</td>
</tr>
<tr>
<td class="cell1">First Name</td>
<td>
<input class="cell2" type="text" placeholder="请输入First Name">
</td>
</tr>
<tr>
<td class="cell1">Last Name</td>
<td>
<input class="cell2" type="text" placeholder="请输入Last Name">
</td>
</tr>
<tr>
<td class="cell1">Address</td>
<td>
<input class="cell2" type="text" placeholder="请输入Address">
</td>
</tr>
<tr>
<td class="cell1">City</td>
<td>
<input class="cell2" type="text" placeholder="请输入所在City">
</td>
</tr>
<tr>
<td class="cell1">State</td>
<td>
<select class="cell4" type="text" placeholder="请输入State">
<option>[Select State]</option>
<option>111</option>
<option>222</option>
</select>
</td>
</tr>
<tr>
<td class="cell1">County</td>
<td>
<input class="cell2" type="text" placeholder="请输入County">
</td>
</tr>
<tr>
<td class="cell1">Email Address</td>
<td>
<input class="cell2" type="email" placeholder="请输入Email Address">
</td>
</tr>
<tr>
<td class="cell1">Select Interest</td>
<td>
<input type="radio"/>Technology
<input type="radio"/>Enterprise
<input type="radio"/>Research
<input type="radio"/>Government
<input type="radio"/>People
<input type="radio"/>Life Style
<input type="radio"/>Opinion
</td>
</tr>
<tr>
<td class="cell1">Question</td>
<td>
<select class="cell5" type="text" placeholder="请输入Question">
<option>[Select Question]</option>
<option>你喜欢什么?</option>
<option>你喜欢我吗?</option>
</select>
</td>
</tr>
<tr>
<td class="cell1">Answer</td>
<td>
<input class="cell2" type="text" placeholder="请输入Answer">
</td>
</tr>
<tr>
<td> </td>
<td>
<input class="cell3" type="button" value="Submit Information" >
<input class="cell3" type="button" value="Reset Form" >
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>