0
滾動條手柄在我的頁面中不可見。我試着將overflow-x設置爲自動並滾動#cust1和#cust2 div。滾動條手柄不可見
我還需要五個div來從頁面底部的一個滾動條控制水平滾動。 (Div's #one,#two,#three,#four和#custTimeline)我不想爲每個客戶div分配滾動條。
請幫忙。 https://jsfiddle.net/c71ytuxz/1/
var c = document.getElementById("custTimeline");
var ctx = c.getContext("2d");
ctx.font = "20px Georgia";
ctx.save();
ctx.rotate(-90*Math.PI/180);
var baseLoc = 130;
var hours = ["5AM","6AM", "7AM","8AM","9AM","10AM","11AM","12 NOON","1PM","2PM","3PM","4PM","5PM","6PM", "7PM", "8PM", "9PM", "10PM", "11PM", "12PM"];
for(i = 0; i < hours.length; i++) {
if (i == 0) {
ctx.fillText(hours[i], -120, baseLoc);
}
else {
baseLoc += 90;
ctx.fillText(hours[i], -120, baseLoc);
}
}
ctx.restore();
#header {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100px;
background: lightgrey;
}
#cust1 {
position: fixed;
left: 0px;
top: 160px;
width: 1500px;
height: 150px;
background: lightgrey;
overflow-x: scroll;
overflow-y: hidden;
margin-bottom: 10px;
}
#one {
width: 8%;
height: 150px;
background: darkgrey;
float: left;
text-align: center;
}
#two {
margin-left: 25%;
width: 35px;
height: 150px;
background: green;
}
#cust2 {
position: fixed;
top: 320px;
left: 0px;
width: 1500px;
height: 150px;
background: lightgrey;
overflow-x: scroll;
overflow-y: hidden;
}
#three {
width: 8%;
height: 150px;
background: darkgrey;
float: left;
text-align: center;
}
#four {
margin-left: 15%;
width: 35px;
height: 150px;
background: green;
}
<canvas id="custTimeline"
width = "1900"
height = "130"
style = "border:3px solid #aaaaaa;">
</canvas>
<div id="cust1">
<div id="one"><p>
Customer 1
</p></div>
<div id="two"></div>
</div>
<div id="cust2">
<div id="three"><p>
Customer 2
</p></div>
<div id="four"></div>
</div>
綠色區域是到達時間指標,他們應該是狹窄的。 #cust1和#cust2 div的設置爲1500px,每個應該強制滾動條但不起作用。 – mike
@mike這不是滾動條的工作方式......因爲#cust1和#cust2具有'verflow:auto',當它們的_content_大於它們的寬度時,它們會滾動(活動滾動條),而不是因爲它們本身寬於視口......這就是爲什麼我將它們設置爲「100vh」並且使內容更寬,以便您瞭解其工作原理 – LGSon
謝謝,我明白了。我通過在「cust1」和「cust2」內創建了另一個長div,稱爲「filler1」和「filler2」,並將其不透明度設置爲0. [jsfiddle](https://jsfiddle.net/r0zcz8q5/)我的問題的其他部分,我怎樣才能使「custTimeline」控件的「cust1」和「cust2」的滾動條? – mike