我正在使用一个包含多行的表格。只有几行有不止一列。我已经将表格的宽度设置为 980px。但是第一列占980px,第2列超出980px。我使用了表格布局:固定的。它不工作 IE7。
<!DOCTYPE html>
<html>
<head>
<style>
table{
table-layout:fixed;
*table-layout:fixed;
width:960px;
min-width:50px
}
td{
border:1px solid black;
}
</style>
</head>
<body>
<table>
<tr> <td>SomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeText</td></tr>
<tr><td> SomeTextSomeTextSomeTextSomeTextSomeText</td>
<td> SomeTextSomeText</td></tr>
<tr><td>SomeTextSomeText</td> </tr>
</table>
</body>
</html>
我通常使用 hack 来修复 IE,比如 *table-layout:fixed。它适用于 IE8+,但不适用于 IE7。
最佳答案
我得到了答案: Colspan 或 colgroup 可用于根据我们的喜好更改列宽。
<!DOCTYPE html>
<html>
<head>
<style>
table{
table-layout:fixed;
*table-layout:fixed;
width:960px;
min-width:50px
}
td{
border:1px solid black;
}
</style>
</head>
<body>
<table>
<tr> <td colspan ="2">SomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeTextSomeText</td> </tr>
<tr><td colspan="1"> SomeTextSomeTextSomeTextSomeTextSomeText</td>
<td> SomeTextSomeText</td>. </tr>
<tr><td>SomeTextSomeText</td> </tr>
</table>
</body>
</html>
关于html - 表格布局 :fixed is not working IE7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29326251/