這是一個不錯的發現!我必須用這種方法「修復」我的Scroller小部件(我討厭)。
反正固定取向的問題,我發現,這三個寬度設置需要進行設置,盒大小一起。
{ width: 250px; min-width: 250px; max-width: 250px; }
我更新your demo並作出了一些調整,使水平滾動條不會在Chrome中顯示出來。我不知道如何風格滾動條上方的白色盒子,可是...
#tableContainer * {
box-sizing: border-box;
}
/* define height and width of scrollable area. Add 16px to width for scrollbar */
div.tableContainer {
clear: both;
height: 340px;
overflow-y: auto;
overflow-x: hidden;
width: 916px
}
/* Reset overflow value to hidden for all non-IE browsers. */
/* define width of table. Add 16px to width for scrollbar. */
html>body div.tableContainer {
overflow: hidden;
width: 916px
}
/* define width of table. IE browsers only */
div.tableContainer table {
float: left;
width: 900px;
}
/* All other non-IE browsers. */
html>body div.tableContainer table {
width: 916px;
}
/* set table header to a fixed position. WinIE 6.x only
In WinIE 6.x, any element with a position property set to relative and is a child
of an element that has an overflow property set, the relative value translates
into fixed.
Ex: parent element DIV with a class of tableContainer has an overflow property
set to auto
thead.fixedHeader tr { position: relative }
set THEAD element to have block level attributes. All other non-IE browsers this
enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
html>body thead.fixedHeader tr {
display: block
}
/* define the table content to be scrollable
set TBODY element to have block level attributes. All other non-IE browsers
this enables overflow to work on TBODY element. All other non-IE, non-Mozilla
browsers induced side effect is that child TDs no longer accept
width: auto */
html>body tbody.scrollContent {
display: block;
height: 262px;
overflow-y: auto;
overflow-x: hidden;
width: 100%
}
/* define width of TH elements: 1st, 2nd, and 3rd respectively.
Add 16px to last TH for scrollbar padding. All other non-IE browsers. */
table#eventlist td:nth-child(1),
table#eventlist th:nth-child(1),
table#eventlist td:nth-child(2),
table#eventlist th:nth-child(2) {
width: 250px;
min-width: 250px;
max-width: 250px;
}
table#eventlist td:nth-child(3),
table#eventlist th:nth-child(3),
table#eventlist td:nth-child(4),
table#eventlist th:nth-child(4) {
width: 200px;
min-width: 200px;
max-width: 200px;
}
我意識到我可以做出CSS來調整它的一些更多的變化。我認爲它稍微好一點... https://jsfiddle.net/yokonanoda/t671bp8f – yokonanoda