2017-06-09 8 views
-3

enter image description here次のレイアウトを入れ子にすることなくflexで構築することはできますか?

例:

ネストせずにフレックスとレイアウトのこの種を建てすることが可能ですか?純粋に、このような構造で:

<div class="long"> 
</div> 

<div class="short"> 
</div> 

<div class="short"> 
</div> 

<div class="short"> 
</div> 

<div class="short"> 
</div> 
+0

下記参照、およびスクリプトなし。 – LGSon

+0

フレックスボックスでは、容器に固定された高さを設定することができます。 https://stackoverflow.com/q/34480760/3597276 –

答えて

1

確かに。いいえ、その後、あなたはボックスが動的コンテンツに調整したい場合は

* { 
 
    box-sizing: border-box; 
 
} 
 

 
.container { 
 
    display: flex; 
 
    flex-flow: column; 
 
    flex-wrap: wrap; 
 
    max-height: 200px; 
 
    max-width: 320px; 
 
} 
 

 
.long { 
 
    background-color: red; 
 
    border: thin solid darkgray; 
 
    width: 100px; 
 
    height: 200px; 
 
} 
 

 
.short { 
 
    background-color: blue; 
 
    border: thin solid darkgray; 
 
    width: 100px; 
 
    height: 100px; 
 
}
<div class="container"> 
 
    <div class="long"></div> 
 
    <div class="short"></div> 
 
    <div class="short"></div> 
 
    <div class="short"></div> 
 
    <div class="short"></div> 
 
</div>

*

+0

ありがとう! 1つの質問:色付きのdivの間に巨大なスペースがあるのはなぜですか? – alex

+1

デフォルトでは、コンテナdivの幅は0f 100%です。私は今divの間のスペースを減らすためにコードの最大幅を定義しました。 – Gerard

関連する問題