【发布时间】:2016-06-29 05:32:00
【问题描述】:
我正在尝试让一个可滚动的 div 包含在扩展以填充页面的 flex 元素中。目前,它只是溢出了它的容器。
我查看了诸如:Scrolling a flexbox with overflowing content 之类的问题,没有运气
在我的代码中,应该滚动并包含在浅蓝色 div 中的蓝色内容 div 溢出并溢出。
这是我目前的结构:
.base {
background: lightblue;
display: flex;
flex-flow: column;
height: 100vh;
padding: 0 20px;
}
.column {
display: flex;
flex-flow: column;
flex: 1 0 auto;
background: lightgreen;
/* overflow: hidden; */
}
.instructions {
background: red;
display: flex;
flex-flow: column;
}
.header {
background: teal;
}
.content {
background: blue;
overflow: scroll;
}
<div class='base'>
<div class='column'>
<div class='instructions'>
<div class='header'>this is the header</div>
<div class='content'>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
<p>This is content</p>
<p>This is a lot of content</p>
</div>
</div>
</div>
</div>
这里有一个关于 codepen 的例子http://codepen.io/anon/pen/qNryJZ?editors=1100
【问题讨论】: