html - 为什么使用overflow-x=scroll在我的div上忽略滚动条?
问题描述
我的 html 上有一个 div,我想应用一个稍后滚动。
这是html
<div class="section-container mt-5 row" >
<div class="section" v-for="(item,index) in board.sections" v-bind:key="index">
<div class="card-title">
<h5 class="text-center section-header">{{item.name}}</h5>
</div>
</div>
</div>
这是我使用的css:
.section-container{
overflow-x: scroll;
white-space: nowrap;
}
.section{
width: 30%;
margin-left: 2%;
margin-right: 2%;
}
我在另一篇文章中读到这应该通过横向滚动来解决问题,但它被忽略了,我的 div 只是继续堆叠在同一个 div 上。我用错了吗?它们应该水平对齐并滚动浏览所有这些。
解决方案
我认为您正在使用引导程序。引导类row
使元素 aflex-box
带有flex-wrap: wrap
。这会导致您的元素换行到下一行,而不是流出容器。
在你的 section-container 类中添加一个规则来防止 flex-child 包装。
.section-container {
overflow-x: scroll;
flex-wrap: no-wrap;
}
此外,如果您希望孩子具有最小宽度,您可能需要为孩子设置 flex-basis 或 min-width。
我建议你阅读更多关于 flex-box 的内容。这可以帮助您入门。
推荐阅读
- android - 无法在 Android 应用程序 (Admob) 上显示测试广告
- r - R markdown 和 bookdown 来创建简单和复杂的表格(手动——手动)
- r - 如何根据另一个数据集设置的条件对行进行分组?
- python - 这是什么/为什么打印?
- ruby-on-rails - 如何信任关联 ID 参数?
- firebase - 未定义的名称'firebase'颤振
- multipartform-data - 套件脚本:从柜子多部分/表单数据中发布图像
- javascript - 在 codeigniter4 中使用 javascript fetch api 会导致“TypeError:尝试获取资源时出现 NetworkError”。
- python - 如何找到具有偶数区域的图形
- azure - 一般异常 Microsoft Graph API OfficeConversion_ConverterInternal