請試試這個:
HTML
<div id="project-slider">
<div class="container">
<ul class="items-holder">
<li class="item" style="background: blue;"></li>
<li class="item" style="background: red;"></li>
<li class="item" style="background: green;"></li>
</div>
</div>
</div>
<div>
<p>
Just to show that currently the window is scrolling instead of the container.
</p>
</div>
CSS
html, body {
margin: 0;
padding: 0;
background: #12969D;
}
.container {
height: 90vh;
width: 90vw;
padding: 40px 0;
box-sizing: border-box;
border: 1px solid black;
background: #6B00BE;
margin: 5vh auto;
}
ul {
height: 100%;
width: calc(100% + 75px);
padding: 0;
background: #FFBD37;
list-style-type: none;
box-sizing: border-box;
overflow-x: scroll;
overflow-y: hidden;
white-space:nowrap;
}
li {
padding: 10px;
display: inline-block;
background: #FFD787;
height: 100%;
width: 50vw;
border: 1px solid black;
}
DEMO HERE
可以添加代碼 –
只是爲了確認:你想一個解決方案,其中沒有一個無序列表的內容是容器的外部是可見的,但你可以滾動容器內的列表中的每個元素?你想要滾動條是什麼元素? –
請檢查它的先生@EnzioPixel –