帮忙写个html页面,页面包含一个输入框用于输入学生姓名,另外包含一个查询按钮,一个登录管理后台按钮,两个按钮点击后跳转到不同的页面,学生姓名通过post方法传递,另外帮我美化一下页面,页面内容在浏览器的中间显示。
时间: 2023-09-09 11:04:31 浏览: 83
### 回答1:
以下是一个示例 HTML 页面,满足您所述的要求:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>学生信息查询</title>
<style>
/* 美化页面 */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
width: 500px;
padding: 20px;
background-color: #f2f2f2;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-control {
display: flex;
flex-wrap: wrap;
align-items: center;
margin-bottom: 20px;
}
.form-control label {
width: 100px;
margin-right: 20px;
text-align: right;
}
.form-control input[type="text"] {
width: 300px;
height: 36px;
border: 1px solid #ccc;
border-radius: 5px;
padding: 0 10px;
}
.form-control input[type="submit"] {
width: 100px;
height: 36px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<!-- 表单 -->
<form action="/student" method="post">
<!-- 姓名输入框 -->
<div class="form-control">
<label for="name">学生姓名:</label>
<input type="text" id="name" name="name">
</div>
<!-- 查询按钮 -->
<div class="form-control">
<input type="submit" value="查询">
</div>
</form>
<!-- 登录按钮 -->
<form action="/login" method="get">
<div class="form-control">
<input type="submit" value="登录管理后台">
</div>
</form>
</div>
</body>
</html>
```
说明:
- 表单提交时使用了 `post` 方法,并且通过 `name` 属性传递了学生姓名。
- 查询按钮和登录按
### 回答2:
首先,我为您撰写了以下代码来创建一个包含输入框和按钮的HTML页面,并实现跳转功能:
```html
<!DOCTYPE html>
<html>
<head>
<title>学生信息查询</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
}
.container {
text-align: center;
}
input[type="text"] {
padding: 8px;
width: 200px;
font-size: 16px;
border-radius: 4px;
border: 1px solid #ccc;
}
button {
padding: 10px 20px;
font-size: 16px;
background-color: #4CAF50;
color: white;
border-radius: 4px;
border: none;
cursor: pointer;
margin: 10px;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<input type="text" id="studentName" placeholder="请输入学生姓名">
<button onclick="query()">查询</button>
<button onclick="login()">登录管理后台</button>
</div>
<script>
function query() {
var studentName = document.getElementById("studentName").value;
if(studentName) {
location.href = "query.php?name=" + studentName;
}
}
function login() {
location.href = "login.php";
}
</script>
</body>
</html>
```
上述代码中,我们使用了内联CSS样式来美化页面。样式内容包括将页面内容居中、设置输入框和按钮的样式等。在`input`元素中,我们设置了`type`为`text`,以便用户可以输入学生姓名。然后,在查询按钮的`onclick`事件中,我们通过获取输入框中的值,使用`location.href`来实现页面跳转,并将学生姓名以`GET`方式传递给接收页面(假设接收页面是`query.php`)。同样地,在登录管理后台按钮的`onclick`事件中,使用`location.href`实现跳转至登录页面(假设登录页面是`login.php`)。
希望这个HTML页面和样式满足您的需求,如有其他问题请随时提问。
### 回答3:
你好!以下是一个简单的HTML页面示例,满足你的需求:
```html
<!DOCTYPE html>
<html>
<head>
<title>学生查询</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
}
.container {
text-align: center;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #f7f7f7;
}
.input-box {
margin-bottom: 10px;
}
input[type="text"] {
padding: 5px;
width: 200px;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>学生查询</h2>
<div class="input-box">
<label for="name">学生姓名:</label>
<input type="text" id="name" name="name">
</div>
<button onclick="submitForm()">查询</button>
<button onclick="goToAdmin()">登录管理后台</button>
</div>
<script>
function submitForm() {
var name = document.getElementById("name").value;
// 使用Post方式将学生姓名传递到另一个页面
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "query.php");
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "name");
input.setAttribute("value", name);
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function goToAdmin() {
// 跳转到管理后台页面
window.location.href = "admin.php";
}
</script>
</body>
</html>
```
这个页面包含一个输入框用于输入学生姓名,一个查询按钮和一个登录管理后台按钮。当点击查询按钮时,使用POST方法将学生姓名传递到名为“query.php”的页面进行查询。当点击登录管理后台按钮时,直接跳转到名为“admin.php”的管理后台页面。
页面的美化通过CSS样式实现,将页面内容居中显示。整个页面被包裹在一个类名为“container”的div中,该div具有一定的内边距和边框样式。输入框和按钮样式通过选择器进行设置,并使用了一些常见的样式属性。