内側のブロックが互いに続く必要があり、浮いたもののように動作するコンテナがあります。解像度が変更された後にレイアウトが再配置されるため、floatを使用できません。現在、ブロック1(70%幅)と2(30%)の両方が同じ行にある必要がありますが、2番目のブロックは次の行に移動します。
HTML:
<section>
<div>Header</div>
<div>SideRight</div>
<div>Bottom line</div>
</section>
CSS
body * {
box-sizing: border-box;
}
section {
background: #ddd;
display: flex;
flex-direction: column;
max-width:300px;
}
section > div{
padding: 10px;
}
section > div:nth-child(1){
background-color: pink;
width: 70%;
}
section > div:nth-child(2){
background-color: lightgreen;
align-self: flex-end;
width: 30%;
}
section > div:nth-child(3){
background-color: yellow;
}
ここでライブの例を見ることができます:https://plnkr.co/edit/f6LWiQfpRUwYYyW9Dve4?p = Preview
それで、達成することは可能ですか?最後に、次のようになります。
あなたは追加することができますflex-wrap: wrap;
にsection
して削除しflex-direction: column;
、次のように
section {
background: #ddd;
display: flex;
/* flex-direction: column; */
max-width: 300px;
flex-wrap: wrap; //add this
}
あなたは「ボトムライン」をしたい場合は、行全体が追加記入flex-grow: 1;
しますsection > div:nth-child(3)
最終結果は次のようになります
section {
background: #ddd;
display: flex;
/* flex-direction: column; */
max-width: 300px;
flex-wrap: wrap; //new
}
section > div:nth-child(3) {
background-color: yellow;
flex-grow: 1; //new
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加