html - bootstrap-select 选项列表仅与底层组件一样长

标签 html css twitter-bootstrap overflow bootstrap-select

我希望我能解释清楚。我有一张表格,其中显示了 thymeleaf 模板中的数据列表。该表的标题是一种用于过滤其内容的表格。只有当表的内容很短时,我遇到的问题才会显现出来,比如只有一条记录。下面是一些代码来展示它的样子:

<div class="table-responsive">
<form name="fiterScanCodes" th:action="@{'/scanCodes/search'}" method="POST">
    <table class="table table-hover table-striped table-dark">
        <thead>
            <tr>
                <th>Scan Code</th>
                <th>Med</th>
            </tr>
            <tr>
                <th>
                    <input type="text" class="form-control" id="scanCodeFilter" name="scanCodeFilter" th:value="${scanCodeFilter}" 
                        placeholder="Search Scan Code" onchange="this.form.submit()"/>
                </th>
                <th>
                    <select class="form-control selectpicker" id="medFilter" name="medFilter" th:value="${medFilter}"
                        onchange="this.form.submit()" data-live-search="true" title="Select Med"> 
                        <option value="">Search Med</option>
                        <option th:each="med : ${meds}" th:value="${med.id}" 
                            th:text="${med.toString()}" th:selected="${med.id == medFilter}">
                            </option>
                    </select>
                </th>
            </tr>
        </thead>
        <tbody>
            <tr th:each = "scanCode : ${scanCodes}">
                <td th:text = "${scanCode.scanCode}"></td>
                <td th:text = "${scanCode.med.toString()}"></td>
            </tr>
        </tbody>
    </table>
</form>
</div>

我遇到的问题是选项的可见部分仅与表格本身一样长:

enter image description here

随着表格变大,我可以看到越来越多的选项,直到它最终完全显示出来:

enter image description here

是什么控制了这种行为,我怎样才能一直显示完整的选项列表?我尝试将 selectpicker 类的溢出属性设置为可见,但没有成功。

最佳答案

当然,我在写这篇文章后 2 分钟找到了我的答案,同时尝试了半随机的事情!我尝试设置 overflow 属性的方向是正确的,但我错误地将它应用于 selectpicker 类。 overflow 属性需要在底层容器上设置,而不是组件本身。下面的 CSS 修复了它:

.table-responsive
{
    overflow: visible;
}

关于html - bootstrap-select 选项列表仅与底层组件一样长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55995908/

相关文章:

html - 几乎全屏标题问题

html - 我如何在 bs4 的轮播中集中和缩小两个图像之间的差距?

html - 输入的宽度是否比其他元素占用更多空间?

javascript - 为什么 bootstrap-select 会多次触发?

html - 在 Bootstrap 4 上更改下拉图标

javascript - 如何修复 tinyMCE 卡在 iPad 上,下方有 Canvas ?

css - 页面右侧的 Twitter bootstrap 白色间隙

CSS 标题导航 UL/LI 链接...我做错了什么?

javascript - 从解析的 JSON 对象中获取元素

javascript - 如何以一半显示图像或裁剪它自己的大小?