我想讓div 1變大,然後div 2和3疊在它旁邊並且高度相等,但它會根據內容和再有DIV 4,5,6上的下一行,但相等的寬度爲2和3Flexbox模式1/3/3列和行組合
------------------
| | 2 |
| 1 |-----|
| | 3 |
------------------
| 4 | 5 | 6 |
------------------
<div class="d-flex">
<div class="hero">I'm Box 1<br>Some other text
<br>Some other text
<br>Some other text
<br>Some other text</div>
<div class="hero">Box 2</div>
<div class="hero">Box 3</div>
<div class="hero">Box 4</div>
<div class="hero">Box 5</div>
<div class="hero">Box 6</div>
</div>
CSS
html,
body {
}
body {
font-family: 'Raleway', sans-serif;
font-size: 22px;
font-weight: 600;
text-transform: uppercase;
color: #FFF;
}
.d-flex {
display: flex;
flex-wrap: wrap;
text-align: center;
}
.d-flex > div {
margin: 5px;
}
.hero {
flex: 0 0 calc(33.33% - 10px);
padding: 30px 0;
background: #7e58b7;
border-radius: 3px;
}
.hero:first-child { flex-basis: calc(66.66% - 10px); }
.hero:nth-child(2),
.hero:nth-child(3) {
flex: 1 0 0;
}
@media (max-width: 736px) {
.hero { flex-basis: calc(50% - 10px); }
.hero:first-child { flex-grow: 1; }
}
* {
box-sizing: border-box;
}
我這兒也有一個小提琴https://jsfiddle.net/abennington/jqc0gkyo/4/
謝謝你很多提前!
你想箱2和3是在彼此的頂部? – sol
不幸的是,flexbox不是用來處理一條線上的元素大小與另一條線上的元素大小的關係 - 只有一條線上的元素大小與同一條線上的其他元素相關的大小。 – Adam
事實上,flexbox無法實現。我也不完全清楚這應該是什麼樣子。 –