Flexbox Ordering
by mattoconnell408
HTML
<div class="bar bar-2">
<div class="icon icon-1"></div>
<div class="icon icon-2"></div>
<div class="icon icon-3"></div>
<div class="username">
Chris
</div>
<div class="search">
<input type="search" placeholder="search..." />
</div>
<div class="inner">
<div class="icon icon-4" style="background: blue;"></div>
<div class="icon icon-5"></div>
</div>
</div>
SCSS
*,
*:before,
*:after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
padding: 20px;
font: 100% sans-serif;
}
.bar {
display: flex;
align-items: center;
width: 100%;
background: #eee;
padding: 20px;
margin: 0 0 20px 0;
> * {
margin: 0 10px;
}
}
.icon {
width: 30px;
height: 30px;
background: #ccc;
border-radius: 50%;
}
.search {
flex: 1;
input {
width: 100%;
}
}
.bar-2 {
.username {
order: 2;
}
.icon-3 {
order: 3;
}
}
.inner {
display: flex;
flex-direction: column;
}
@media (max-width: 650px) {
.bar {
flex-wrap: wrap;
}
.icon {
order: 0 !important;
}
.username {
order: 1 !important;
width: 100%;
margin: 15px;
}
.search {
order: 2 !important;
width: 100%;
}
.icon.icon-5 {
order: 0 !important;
}
.icon.icon-4 {
order: 1 !important;
}
}