表格放在Div中,設定Div的寬度和高度(不能用百分比),并設定縱向滾動條始終顯示。
設定表格的寬度比Div小一個滾動條的寬度(如Div寬度為500,滾動條寬度為16,則表格的寬度應該設定為500-16=484)。
表格采用 thead,th标簽
範例:包括html檔案和css檔案
《test.html》:
《css1.css》
*************************************************************
div {
width:500px;
height:100px;
overflow-y:scroll;
overflow-x:none;
}
table {
width:484px;
}
thead tr {
POSITION: relative; TOP:0px;
background:#cccccc;
}
tr {
background:#222222;
}
*************************************************************