【问题标题】:Scrollable two column layout based on gentelella基于gentelella的可滚动两列布局
【发布时间】:2016-10-14 16:14:40
【问题描述】:
【问题讨论】:
标签:
css
html
twitter-bootstrap
scroll
gentelella
【解决方案1】:
如果你给容器元素的高度为 100vh,那么你可以给它的子元素 100% 的高度。
vh 是 视口高度 的测量单位,它可以为您提供一些基础后续相对测量的依据。
您的问题是可滚动元素的高度不正确。
设置 max-height 或 height 会有所帮助。
在此示例中,将所有列的最小高度设为 100%,然后将要滚动的列的最大高度设为 100% 并滚动溢出 - 例如
.column {
display: inline-block;
width: 33%;
min-height: 100%;
vertical-align: top;
margin: auto;
font-size: 3em; /* This is just for the example, so we have enough stuff to scroll */
}
#column2 {
overflow-y: scroll;
max-height: 100%;
}
<div class="column" id="column1">
</div>
<div class="column" id="column2">
content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>content to be scrolled
<br>
</div>
<div class="column" id="column3">
</div>
关键是定义要滚动其内容的元素的高度。