Why, in this example, is the .main
element (blue) dividing space only with .aside-1
(yellow) and .aside-2
(pink), and not with all elements?
We have a wrapper that is putting all elements occupying one line.
In .main
we say flex: 3 0px
, which I think says, this element will be 3x bigger than the other four elements and will occupy 3/(3+1+1+1+1).
However, I've noticed that with a nowrap
wrapper the smallest item is .main
.
And with wrap
, it divides with the two closest elements.
Can't understand this.
.wrapper {
display: flex;
flex-flow: row wrap;
font-weight: bold;
text-align: center;
}
.wrapper>* {
padding: 10px;
flex: 1 100%;
}
.header {
background: tomato;
}
.footer {
background: lightgreen;
}
.main {
text-align: left;
background: deepskyblue;
height: 50vh;
flex: 3 0px;
}
.aside-1 {
background: gold;
}
.aside-2 {
background: hotpink;
}
.aside {
flex: 1 auto;
}
.aside-1 {
order: 1;
}
.main {
order: 2;
}
.aside-2 {
order: 3;
}
.footer {
order: 4;
}
<div class="wrapper">
<header class="header">Header</header>
<article class="main">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est.
Mauris placerat eleifend leo.</p>
</article>
<aside class="aside aside-1">Aside 1</aside>
<aside class="aside aside-2">Aside 2</aside>
<footer class="footer">Footer</footer>
</div>