I use flexbox to align my 4 elements per line.

Then I want to break it down for mobile as follows:

I have successfully reordered the elements here:
.flexcontainer { display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; -webkit-align-items: flex-start; align-items: flex-start; width: 90%; margin: 0 auto; background: red; } .flexcontainer>div { height: 100px; width: 25%; background-color: #E46119; border: 1px solid #626262; margin: 3px; } .flexcontainer>div:nth-of-type(1) { -webkit-flex: 1 0 0; flex: 1 0 0; order: 3; } .flexcontainer>div:nth-of-type(2) { -webkit-flex: 2 0 0; flex: 2 0 0; order: 2; } .flexcontainer>div:nth-of-type(3) { -webkit-flex: 2 0 0; flex: 2 0 0; order: 1; } .flexcontainer>div:nth-of-type(4) { -webkit-flex: 1 0 0; flex: 1 0 0; order: 4; }
<div class="flexcontainer"> <div>one</div> <div>two</div> <div>three</div> <div>four</div> </div>
But I was fixated on how to split child elements "two" and "three" into their own lines. And then, how to make the element "one" and "four" each 50% in its own line.
Am I trying to do this without additional HTML markup? Thank you for your advice.
.flexcontainer { display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; -webkit-align-items: flex-start; align-items: flex-start; width: 90%; margin: 0 auto; background: red; } .flexcontainer>div { height: 100px; width: 25%; background-color: #E46119; border: 1px solid #626262; margin: 3px; } .flexcontainer>div:nth-of-type(1) { -webkit-flex: 1 0 0; flex: 1 0 0; } .flexcontainer>div:nth-of-type(2) { -webkit-flex: 2 0 0; flex: 2 0 0; } .flexcontainer>div:nth-of-type(3) { -webkit-flex: 2 0 0; flex: 2 0 0; } .flexcontainer>div:nth-of-type(4) { -webkit-flex: 1 0 0; flex: 1 0 0; }
<div class="flexcontainer"> <div>one</div> <div>two</div> <div>three</div> <div>four</div> </div>
html css html5 flexbox css3
nick
source share