设置表格列宽

时间:2012-03-09 18:26:37

标签: css html-table

我尝试通过调整 宽度来实现:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Page</title>
<style type="text/css">
div {width:100%; overflow:auto;}
table, td {border:1px solid #000;}
td {width:1000px;}
</style>
</head>
<body>
<div>
<table>
<tr>
<td>First cell</td>
<td>Second cell</td>
<td>Third cell</td>
</tr>
<tr>
<td>Forth cell</td>
<td>Fifth cell</td>
<td>Sixth cell</td>
</tr>
</table>
</div>
</body>
</html>

但它没有用。我错过了什么?

1 个答案:

答案 0 :(得分:1)

必须修复您的表格布局才能修复列宽:

<table style="width: 100%; table-layout: fixed;">