我只是無法弄清楚什麼是問題,我有一個HTML表,我想讓表頭保持在一個固定的位置,保持最長td的寬度。我需要它的腳本和th元素必須是固定的寬度沒有JavaScript和簡單的CSS 使表頭保持在一個固定的位置,並保持最長的寬度td
BODY {
font-family: Arial;
font-size: 8pt
}
.focim {
margin-left: 400px;
color: Black;
font-family: Arial;
font-size: 15pt;
font-weight: 900;
padding-bottom: 20px;
text-decoration: underline
}
Time {
color: Black;
font-family: Arial;
font-size: 10pt;
font-weight: 500;
padding-bottom: 20px
}
TABLE {
border-width: 3px;
border-style: solid;
border-color: Black;
border-collapse: collapse;
}
TH {
font-family: Arial;
font-size: 10pt;
border-width: 1px;
border-style: solid;
border-color: Black;
background: #b3b3b3;
}
TR:first-child {
position: fixed;
margin-top: 0px;
white-space: nowrap;
}
TD {
white-space: nowrap;
border-width: 1px;
padding: 3px;
border-style: solid;
border-color: Black
}
TD:first-child {
background-color: #C19A6B;
padding-right: 5px;
padding-left: 5px
}
TR:nth-child(even) {
background-color: #dddddd;
}
tr:hover td {
background: #4E5066;
color: #FFFFFF;
border-top: 1px solid #22262e;
border-bottom: 1px solid #22262e;
}
<table>
<colgroup>
<col/>
<col/>
<col/>
<col/>
</colgroup>
<tr>
<th>Name</th>
<th>IP_Addresses0</th>
<th>Domain</th>
<th>LocalPath0</th>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
<tr>
<td>name</td>
<td>someip</td>
<td>domain</td>
<td>path</td>
</tr>
</table>
什麼是你遇到的問題? – 2014-09-26 09:11:07
可能的重複http://stackoverflow.com/questions/673153/html-table-with-fixed-headers – 2014-09-26 09:16:18