I'm using Flexbox to make a responsive site (first time I've done either of those, bear in mind) and it was all going well until I realised at some point that flex items with the same properties weren't behaving the same way.
Have a look at this, I had some issues with the page in Chrome even though I ran the CSS through Autoprefixer, but that's another issue. If you have issues with this, it might be an idea to open it in Safari, which I started testing it in. You'll have to narrow the JS window to make the left-hand side visible. https://jsfiddle.net/5p7fcmxb/1/
It's ugly as sin, since I made everything different colours to differentiate them and switched everything to default fonts for the purposes of this thread. Anyway, the basic problem is that the #headerleft
, #blueleft
and #footerleft
should line up perfectly, since they have the same flex properties, as shown below:
#headerleft {
background-color: red;
height: 75px;
-webkit-box-ordinal-group: 2;
-ms-flex-order: 1;
order: 1;
-webkit-box-flex: 1;
-ms-flex: 1 2 250px;
flex: 1 2 250px;
}
#blueleft {
background-color: yellow;
-webkit-box-ordinal-group: 5;
-ms-flex-order: 4;
order: 4;
-webkit-box-flex: 1;
-ms-flex: 1 2 250px;
flex: 1 2 250px;
}
#footerleft {
background-color: red;
height: auto;
padding: 0px;
margin: 0px;
-webkit-box-ordinal-group: 8;
-ms-flex-order: 7;
order: 7;
-webkit-box-flex: 1;
-ms-flex: 1 2 250px;
flex: 1 2 250px;
}
But if you expand that JSfiddle window out, you can see that they're all different widths. At first I thought since they're in separate header
, middle
, and footer
divs, which are themselves children of the overall #container
div, they might be wrapping slightly to the left of the screen for some reason. I set everything 10px from the left and they all lined up at that side, so this seems to be an issue with the growth. If I shrink the page as narrow as it will go, the #blueleft
and #footerleft
elements are invisble, yet the #headerleft
div still can still be seen. You might have noticed the middle and right-hand divs don't line up either, but the answer to the problem of the left-hand divs should apply to them too.
The idea was that the text in #headermiddle
and #footermiddle
would line up perfectly with the #contentbox
div, and I'm sure I remember everything lining up at different viewport sizes when I was working on this yesterday, so I'm not sure if I've done something to break it along the way.
(If you're wondering why I have three flex containers in the first place, as opposed to having one flex container with just three main columns, it's so I could get the header, content box and footer text aligning, as well as having the content box expand according to how much text is inside. I suspect there is an easier way to achieve all of that that I'm not aware of (again, I've been properly doing this for about five or six weeks now) and having those three flex containers was where I went wrong at the first step.)