【发布时间】:2018-02-23 05:32:07
【问题描述】:
我是 CSS 的初学者。我试图创建一个表格,其中第一列的宽度是固定的,并且必须有一个滚动条。对于剩下的列,我希望它们均匀地分布在整个网页上。
我可以为第一列创建滚动条,但它出现在每一行中,这不是我想要的。我仍然希望每一列都是可滚动的,但滚动条应该只在最后一行下方出现一次。
有人可以帮我吗?
#customers {
font-size: 10px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
table-layout: fixed;
}
#customers td,
#customers th {
border: 1px solid #ddd;
padding: 8px;
overflow-x: auto;
}
#customers tr:nth-child(even) {
background-color: #f2f2f2;
}
#customers tr:hover {
background-color: #ddd;
}
#customers th {
padding-top: 6px;
padding-bottom: 6px;
text-align: left;
background-color: #4CAF50;
color: white;
}
.col {
width: 3%;
}
<table id="customers">
<colgroup>
<col width=500px>
<col width=5% span="11">
</colgroup>
</table>
【问题讨论】:
标签: html css html-table