2つのdivの内側にフレックスカラムコンテナがあります。最初のdivには残りのスペースが大きくなるようにflex: 1
があります。 2番目のdivは固定された高さです。コンテナはビューポート全体を取る固定されたdiv内にあることに注意してください。コンテナが最小サイズに達したときにFlexboxがオーバーフローする
問題は、コンテナがコンテンツに収まるには小さすぎると、最初のdivのコンテンツが2番目のコンテンツの下にオーバーフローすることです。ここで
.test {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: red;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
//min-height: 500px;
}
.child1 {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.child2 {
width: 100%;
display: flex;
justify-content: center;
}
span {
padding: 20px;
}
span:first-child {
margin-top: auto;
}
span:last-child {
margin-bottom: auto;
}
<div class="test">
<div class="child1">
<span>Test1</span>
<span>Test2</span>
<span>Test3</span>
<span>Test4</span>
<span>Test5</span>
<span>Test6</span>
<span>Test7</span>
<span>Test8</span>
</div>
<div class="child2">
<span>Test1</span>
<span>Test2</span>
<span>Test3</span>
<span>Test4</span>
</div>
</div>
はcodepen exampleです。
1つの解決策は、コンテナの最小高さを設定することですが、動的で応答性の高い解決策ではありません。
コンテンツ全体が収まらないときに、コンテナのオーバーフロー動作を実現する方法を教えてもらえますか?
位置を使用する理由:固定します。 ??原因:http://codepen.io/gc-nomade/full/jAaoGQ//http://codepen.io/gc-nomade/pen/jAaoGQは正常です.... –
@GCyrillus 'position:fixed'は次のとおりです。私の重なり合ったメニューのために。私はすべてが自分のプロジェクトに似ていることを確認しています。 – Simon
大丈夫です、そしてそれを修正するオーバーフローを追加し、フレックス値(chromeを含む)を更新してください。http://codepen.io/gc-nomade/pen/EybzpV –