In the code, there are three divs arranged in the DOM by div-00#.
I am seeking to achieve the following layout using flexbox (for width >= 460px) as shown in the images below:
https://i.sstatic.net/I2PFQ.png
Added: 18-12-16 -
https://i.sstatic.net/vQiHg.png
Can anyone provide guidance on how to implement this using flexbox?
There is also a second issue with the tab order, but I would like to address the layout first.
ON MOBILE (say < 460px) - within the .div-main:
All divs are 100% of the parent div, ordered .div-001 -div-002 .div-003.
ON DESKTOP (say >= 460px) - within the .div-main:
Due to varying heights, I am avoiding the use of floats, as illustrated in this desktop layout
https://i.sstatic.net/STcWe.png.
.div-001 -- Position: Top Right. Height: Varying. Width: 20%. Ideally, the tab index should be 2 (hence using flex to order this as '2'), but note that the order is dictated by the DOM.
.div-002 -- Position: Top Left. Height: Varying. Width: 80%. Ideally, the tab index should be 1 (hence using flex to order this as '1').
.div-003 -- Position: Right (Directly below .div-003). Height: Varying. Width: 20%. Ideally, the tab index should be 3 (hence using flex to order this as '3').
The order is of significant importance.
* {
margin: 0;
padding: 0;
border: 0;
}
a:focus,
a:hover {
color: red;
}
.header,
.footer {
width: 100%;
max-width: 1220px;
margin: 0 auto;
background: #000;
}
.header {
height: 50px;
}
.footer {
height: 20px;
}
.div-main {
width: 90%;
max-width: 1200px;
margin: 0 auto;
padding: 10px 0;
}
.div-main > div {
min-height: 50px;
box-sizing: border-box;
border: 1px solid #f00;
padding: 10px;
}
@media all and (min-width: 460px) {
.div-main {
display: flex;
flex-direction: column;
}
.div-desktop-left {
width: 80%;
margin-right: auto;
}
.div-desktop-right {
width: 20%;
margin-left: auto;
}
.div-001 {
height: 70px;
order: 2;
}
.div-002 {
align-self: flex-start;
height: 50px;
order: 1;
}
.div-003 {
height: 20px;
order: 3;
}
}
<header class="header"></header>
<div class="div-main">
<div class="div-001 div-mobile-001 div-desktop-002 div-desktop-right div-desktop-right-001"><a href="#">Desktop link 002</a></div>
<div class="div-002 div-mobile-002 div-desktop-001 div-desktop-left div-desktop-left-001"><a href="#">Desktop link 001</a></div>
<div class="div-003 div-mobile-003 div-desktop-003 div-desktop-right div-desktop-right-002"><a href="#">Desktop link 003</a></div>
</div>
<footer class="footer"></footer>