的jsfiddle:https://jsfiddle.net/jefftg/1chmyppm/滾動列表頭水平
橙色標題列和所述白名單的行一起水平滾動,這是期望的。但是,我希望白名單行垂直滾動,橙色標題固定在頂部。他們目前沒有。我正在尋找這個在HTML5/CSS3的現代瀏覽器中工作。
CSS
.container {
width: 800px;
height: 600px;
overflow-x: auto;
overflow-y: hidden;
}
.header-container {
display: flex;
}
.header-cell {
height: 40px;
min-width: 500px;
background-color: orange;
border: 1px solid red;
}
.data-container {
overflow-y: auto;
overflow-x: hidden;
display: inline-block;
}
.data-row {
overflow-x: hidden;
display: flex;
}
.data-row-cell {
height: 30px;
min-width: 500px;
background-color: white;
border: 1px solid black;
}
HTML
<div class="header-container">
<div class="header-cell">A</div>
<div class="header-cell">B</div>
<div class="header-cell">C</div>
<div class="header-cell">D</div>
</div>
<div class="data-container">
<div class="data-row">
<div class="data-row-cell">
A1
</div>
<div class="data-row-cell">
B1
</div>
<div class="data-row-cell">
C1
</div>
<div class="data-row-cell">
D1
</div>
</div>
......
</div>
你可能想嘗試張貼的答案前執行片斷.. 。它不起作用,標題欄水平地與其他標題欄分開滾動,而OP則希望它們一起滾動... – webeno
感謝您提請我注意,我會立即修改我的代碼:) – Sybarium
感謝@webeno – Sybarium