【发布时间】:2020-11-20 03:12:50
【问题描述】:
screenshot of the problem scrolling
例子:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet"/>
<div class="d-flex overflow-hidden" style="max-width:200px; max-height:200px;">
<div class="d-flex flex-column flex-fill bg-warning overflow-hidden">
<div class="d-flex flex-fill bg-success"></div>
<div class="d-flex flex-shrink-0 overflow-auto">
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px; height:40px;">abc</div>
</div>
</div>
<div class="d-flex flex-column flex-shrink-0 bg-dark overflow-auto">
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
<div class="p-2 border border-light text-light" style="width: 40px;">abc</div>
</div>
</div>
https://jsfiddle.net/p6khs5q9/
基本上,当内容足够大以至于可以滚动时,我为自己准备了一个带有项目的垂直 flex 容器(不是固定大小,示例中的右侧栏),滚动条与容器重叠而不是增加容器的宽度,但是这个问题只在垂直条中很明显,在同一个例子中,我得到了水平容器,它在调整大小时垂直扩展容器以容纳滚动条。
我不确定出了什么问题,因为逻辑上它应该只是扩展以容纳额外的内容,但滚动条似乎违反了我的逻辑规律:p
如果我不知所措,我将不胜感激有关此问题的任何反馈或提示。
编辑:更新了小提琴以设置最大宽度/高度,我也在寻找一个跨浏览器解决方案,因为 chrome 有时似乎可以工作,但 IE/Edge/FF 显示错误的行为,我添加了一个截图内容重叠的实际问题是挤压而不是推出。
【问题讨论】:
标签: css twitter-bootstrap flexbox overflow