在提供的示例中,水平滾動容器應該儘可能向左和向右滾動,而垂直滾動容器將頁面從屏幕上展開而不允許任何滾動。滾動條出現,但它被禁用。爲什麼溢出-x工作,但溢出不是?
這個想法是在水平滾動容器之後讓垂直滾動容器覆蓋屏幕的其餘部分。
考慮到臥式容器在本例中40像素高,我設置的最大高度的垂直容器作爲calc(100% - 40px)
#container-scroll-horiz
{
width: 100%;
height: 40px;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
border: 1px solid blue;
}
#container-scroll-horiz .item
{
display: inline-block;
width: 20vw;
height: 50px;
border: 1px solid black;
}
#container-scroll-vert
{
width: 100%;
max-height: calc(100% - 40px);
overflow-x: hidden;
overflow-y: scroll;
border: 1px solid red;
}
#container-scroll-vert .item
{
width: 100%;
height: 20vh;
border: 1px solid purple;
}
<div id="container-scroll-horiz">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="container-scroll-vert">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>