能用,但不是很好的解决方案
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>thead不隐藏</title>
<style>
fieldset {
width: 100%;
height: 200px;
min-height: 200px;
}
table {
width: 100%;
}
th, td {
width: 25%;
text-align: center;
}
.overflow_table {
width: 100%;
max-height: 120px;
overflow-y: auto;
}
::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
border-radius: 4px;
}
::-webkit-scrollbar {
width: 6px;
height: 6px;
background-color: transparent;
border-radius: 3px;
}
</style>
</head>
<body>
<form action="">
<fieldset>
<legend>用户信息</legend>
<table>
<thead>
<tr>
<th>ID</th>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
</tr>
</thead>
</table>
<div class="overflow_table">
<table>
<tbody>
<tr>
<td>1</td>
<td>小明</td>
<td>12</td>
<td>男</td>
</tr>
<tr>
<td>2</td>
<td>小红</td>
<td>11</td>
<td>女</td>
</tr>
<tr>
<td>3</td>
<td>小明</td>
<td>12</td>
<td>男</td>
</tr>
<tr>
<td>4</td>
<td>小红</td>
<td>11</td>
<td>女</td>
</tr>
<tr>
<td>5</td>
<td>小明</td>
<td>12</td>
<td>男</td>
</tr>
<tr>
<td>6</td>
<td>小红</td>
<td>11</td>
<td>女</td>
</tr>
<tr>
<td>7</td>
<td>小明</td>
<td>12</td>
<td>男</td>
</tr>
<tr>
<td>8</td>
<td>小红</td>
<td>11</td>
<td>女</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
</form>
</body>
</html>