实现思路:在表单外层套一层div,设置div的样式
实现效果:
实现代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登录</title>
<style>
.div1{
position: fixed;
width: 100%;
height: 100%;
}
.form1{
position: absolute;
top: 30%;
left: 0;
right: 0;
margin: 0 auto;
border: 1px solid blue ;
width: 500px;
padding: 5px;
}
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<div class="div1">
<form action="" class="form1">
<table id="myTable" align="center">
<tr>
<th>总体信息</th>
<th>输入列表</th>
</tr>
<tr>
<td>用户名</td>
<td><input type="text" placeholder="请输入用户名"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="text" placeholder="请输入密码"></td>
</tr>
<tr>
<td></td>
<td>     <input type="submit">      <input type="reset"></td>
</tr>
</table>
</form>
</div>
<script>
const table = document.getElementById("myTable");
const rows = table.getElementsByTagName("tr");
for (let i = 1; i < rows.length; i++) {
rows[i].addEventListener("mouseover", function() {
this.style.backgroundColor = "blue";
});
rows[i].addEventListener("mouseout", function() {
this.style.backgroundColor = "";
});
}
</script>
</body>
</html>