我有一个HTML表格,我希望前几列很长。我在CSS中这样做:为什么我的HTML表格不尊重我的CSS列宽?
td.longColumn
{
width: 300px;
}
,这里是我的表
<table>
<tr>
<td class='longColumn'></td>
<td class='longColumn'></td>
<td class='longColumn'></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
[ . . and a bunch more columns . . .]
</tr>
</table>
的简化版本,出于某种原因,该表似乎让这列< 300像素的时候也有很多列。我基本上希望它保持这个宽度,不管怎样(只需增加水平滚动条)。
表格在里面的容器没有任何类型的最大宽度,所以我不知道为什么它压缩这个列而不是尊重这个宽度。
反正有,所以无论如何,这个列会保持一定的宽度?
这里是外容器div的CSS:
#main
{
margin: 22px 0 0 0;
padding: 30px 30px 15px 30px;
border: solid 1px #AAAAAA;
background-color: #fff;
margin-bottom: 30px;
margin-left: 10px;
_height: 1px; /* only IE6 applies CSS properties starting with an underscrore */
float: left;
/*width: 1020px;*/
min-width:1020px;
display: block;
overflow: visible;
z-index: 0;
}
我不得不添加'table-layout:fixed;宽度:100%;'它工作。谢谢! – nrodic 2016-01-18 19:19:15
这个和nrodic的评论帮助了我,谢谢! – 2017-03-10 19:16:36