请试试这个:
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 –