width属性设置全表格边框
实例代码;
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
table,th,td{
border:1px solid black;
text-align:center;
}
table{
width:100%;
}
p{
color:red;
}
</style>
</head>
<body>
<h1>css全表格边框</h1>
<table>
<tr>
<th>姓名</th>
<th>年龄</th>
</tr>
<tr>
<td>张三</td>
<td>18</td>
</tr>
<tr>
<td>李四</td>
<td>15</td>
</tr>
</table>
<p>注:请拉动浏览器窗口查看表格宽度大小。</p>
</body>
</html>
运行效果:
评论