【发布时间】:2016-09-09 02:01:59
【问题描述】:
基本上,我有两列,每列都有不同高度的行 div(动态内容)。在右列,底部 div 有一组可滚动的内容。我想要做的是能够使可滚动的 div 具有最大高度,使其底部与第一列中 div 的末尾对齐。
我看到我的问题和How do I keep two divs that are side by side the same height? 之间的最大区别是我的 2 个 div 不是从同一点开始(由于与 IE 的兼容性问题,我不想使用 flexbox)
非常简单的 plunkr:http://plnkr.co/edit/P1yvJon24xOeb3B9as3P?p=preview
HTML
<div class="row">
<div class="col-md-8">
<div class="row row1">randomly heighted content</div>
<div class="row row2">
<p>randomly heighted content</p>
<p>randomly heighted content</p>
<p>randomly heighted content</p>
<p>randomly heighted content</p>
<p>randomly heighted content</p>
</div>
</div>
<div class="col-md-4">
<div class="row row3">
<p>random content</p>
</div>
<div class="row row4">
<div class="scroll-container">
<div class="scroll">
<p>item1</p>
<p>item2</p>
<p>item3</p>
<p>item4</p>
<p>item5</p>
<p>item6</p>
</div>
</div>
</div>
</div>
</div>
(在 plunkr 中,我希望 item1..item6 与红色 div 的底部对齐)
CSS
.row1 {
background-color: yellow;
}
.row2 {
background-color: red;
}
.row3 {
background-color: blue;
}
.row4 {
background-color: green;
}
.scroll {
overflow-y: scroll;
max-height: 100px;
}
我尝试过的事情: 1)为每个div设置固定高度。这不起作用,因为我需要高度随其他 div 的内容而变化。此外,内部内容不响应固定高度。
2) 我不认为我想使用表格,因为 a) 我听说它的风格很糟糕 b) 没关系/真的不应该是 row1 和 row3 的高度相同
3) Flexbox 是个问题,因为它与百分比填充配合起来效果很差。左上角的 div 是一个带有 0 高度 padding-bottom 技巧的视频,以使其正确预加载空间。因此,一种选择是找到一种绕过 padding-bottom 技巧的方法,然后使用弹性框。
4) 奇怪的填充:100000px;边距:-1000000px;当我尝试时,这个技巧没有奏效,但是我可能只是错过了一个额外的步骤
【问题讨论】: