我有类似以下内容:
#page {
height: 200px; /* just for illustration, would be 100vh */
border: 1px solid black; /* just for illustration */
display: flex;
flex-direction: column;
}
#nav {
height: 30px;
background-color: lightBlue;
flex: none;
}
#content {
background-color: lightGreen;
display: flex;
flex: 1 1 auto;
}
section {
flex: 1 1 50%;
padding: 5px;
margin: 5px;
border: 1px solid black;
}
.problem {
color: white;
background-color: red;
height: 500px;
overflow-y: auto;
}
<div id="page">
<div id="nav">
I'm a nav bar!
</div>
<div id="content">
<section>
Stuff
</section>
<section>
More stuff
<div class="problem">
Oh no I'm huge and should scroll vertically
</div>
</section>
</div>
</div>
我希望页面永远不会滚动,并且我只希望大的红色矩形在<section>
. 我需要添加哪些规则才能使红色矩形了解其父级的边界?
富国沪深
阿波罗的战车
相关分类