【发布时间】:2021-08-25 08:00:58
【问题描述】:
我使用 CSS flex 并排显示两个 div,它们包含在一个包装器中,我一直在尝试让 #myClippetWrapper 内部是我设置高度的地方,所以在 #myClippetWrapper 的子元素中我可以只需设置height: 100%;。
但是你可以通过运行sn-p 看到#myClippetWrapper 内的所有元素都超出了主要部分,它们都挂在主要内容div 之外?
我不想使用overflow: auto,因为我不想要滚动条,我只需要#myClippetWrapper 的子元素不在主部分/ div 之外。
main {
margin: 0 auto;
margin-top: 10px;
margin-bottom: 10px;
padding: 8px;
background-color: red;
width: 100%;
max-width: 50%;
height: auto;
}
#myClippetWrapper {
display: flex;
height: 700px;
}
#clippetNav {
padding: 10px;
width: 250px;
height: 100%;
background-color: #222222;
margin-right: 10px;
}
#codeAndNotesWrapper {
display: flex;
width: 100%;
}
#codeAndNotesWrapper>div {
flex-basis: 100%;
height: 100%;
}
#codeView {
padding: 10px;
/*flex: 0 0 40%;*/
height: 100%;
background-color: #222222;
margin-right: 10px;
}
#noteView {
padding: 10px;
/*flex: 1;*/
height: 100%;
background-color: #222222;
}
#codeNotesEditor {
height: 100%;
background-color: #EAEAEA;
}
<main>
<div id="myClippetWrapper">
<div id="clippetNav">
</div>
<div id="codeAndNotesWrapper">
<div id="codeView">
</div>
<div id="noteView">
<div id="codeNotesEditor">
</div>
</div>
</div>
</div>
</main>
【问题讨论】: