html - 不同列中第一个 div 的高度相同(bootstrap 4)

标签 html css bootstrap-4 flexbox

我有下一个 HTML 结构:

<div class="container">
    <div class="row">
        <div class="col-12 col-sm-12 col-lg-4 col-md-4">
            <div class="title">Some title</div>
                <ul>
                    <li>test 1</li>
                    <li>test 2</li>
                </ul>
            </div>
        </div>

        <div class="col-12 col-sm-12 col-lg-4 col-md-4">
            <div class="title">Some long title </div>
                <ul>
                    <li>test 1</li>
                    <li>test 2</li>
                </ul>
            </div>
        </div>

        <div class="col-12 col-sm-12 col-lg-4 col-md-4" >
            <div class="title">Some very very long title</div>
            <ul>
                <li>test 1</li>
                <li>test 2</li>
            </ul>
        </div>
    </div>
</div>

我需要每个 div.title block 的高度都等于最高的。我该怎么做?

最佳答案

我认为最好的方法是使用表格,因为它们可以自动对齐多列。 Bootstrap 本身无法使多个标题在您提供的 HTML 结构中具有相同的高度。

此外,您要关闭两次 div 标签,请参阅 this example对于固定版本。您正在尝试关闭 title-divs 两次,如下所示:

            <div class="title">Some long title </div>
                <ul>
                    <li>test 1</li>
                    <li>test 2</li>
                </ul>
            </div>

虽然你应该只关闭一个标签一次,因为当前的代码会在不同的浏览器中做一些奇怪的事情。

关于html - 不同列中第一个 div 的高度相同(bootstrap 4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58294440/

相关文章:

html - 使图像与屏幕尺寸成比例并在垂直线上?

html - 如果文档的字体大小以 em 指定,那么 "em"是什么?

html - 将三个自动排序列合并为一个

javascript url 未定义重定向

html - 在标题中获取排队 Logo 和导航

jquery - 响应式数据表不适用于 Bootstrap 4.3.1

javascript - 如何访问 carousel bootstrap4 事件幻灯片以初始化事件

bootstrap-4 - Bootstrap : How to specify different background colours per screen width?

HTML 适当的 div 大小

jquery - 避免绝对定位的 div 滚动