编写一个html登录界面以及跳转结果
时间: 2023-07-13 19:12:37 浏览: 56
好的,我可以帮你编写一个简单的html登录界面并实现跳转结果。以下是示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
background-color: #f1f1f1;
font-family: Arial, Helvetica, sans-serif;
}
.container {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
padding: 20px;
margin: 50px auto;
max-width: 400px;
box-shadow: 0 0 10px #ccc;
}
input[type=text], input[type=password] {
padding: 10px;
margin: 5px 0 15px 0;
display: block;
border: none;
border-radius: 5px;
background-color: #f1f1f1;
width: 100%;
}
input[type=submit] {
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px;
font-size: 16px;
cursor: pointer;
width: 100%;
}
input[type=submit]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>Login Form</h2>
<form action="#" method="post">
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="username" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<input type="submit" value="Login">
</form>
</div>
</body>
</html>
```
这个登录界面包含一个输入用户名和密码的表单,以及一个提交按钮。当用户点击提交按钮时,表单数据将被发送到服务器进行验证,并跳转到登录结果页面。在这里,我们只做一个简单的跳转,没有实际的验证过程。以下是跳转结果页面的示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Result</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h2>Login Result</h2>
<p>Welcome, [username]!</p>
</body>
</html>
```
在这个页面中,我们可以在欢迎消息中使用提交的用户名进行个性化欢迎。请将`[username]`替换为实际的用户名。为了使跳转生效,我们需要在提交按钮上添加一个`formaction`属性,以指定跳转结果页面的URL。修改登录界面的代码如下:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
background-color: #f1f1f1;
font-family: Arial, Helvetica, sans-serif;
}
.container {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
padding: 20px;
margin: 50px auto;
max-width: 400px;
box-shadow: 0 0 10px #ccc;
}
input[type=text], input[type=password] {
padding: 10px;
margin: 5px 0 15px 0;
display: block;
border: none;
border-radius: 5px;
background-color: #f1f1f1;
width: 100%;
}
input[type=submit] {
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
padding: 10px;
font-size: 16px;
cursor: pointer;
width: 100%;
}
input[type=submit]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>Login Form</h2>
<form action="#" method="post">
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="username" required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" required>
<input type="submit" value="Login" formaction="login_result.html">
</form>
</div>
</body>
</html>
```
注意,这里的`formaction`属性指定跳转到`login_result.html`页面。请确保在相同的目录下创建一个名为`login_result.html`的文件,并将上面给出的跳转结果页面代码复制到该文件中。
希望这个示例可以帮助你编写自己的登录界面并实现跳转结果。