What I would like to do is quite particular, so I've drawn a picture to illustrate it:
I can easily implement this:
but it doesn't look good on this site because the E element is much taller than C or D.
What I would like, is for C and D to stack when the browser window is wide, but not when it's medium width.
I'm trying to implement this with CSS and Flexbox, and I've tried grouping together C and D in a div, but this creates problems at the medium layout.
demo
change the flex value as you desired
Flexbox is 1D layout. Of course you can add some nesting, some fixed heights, but it's 1D and isn't perfect solution here.
It's much much better to use CSS Grid Layout here, because it's 2D layout.
If you need IE/Edge support you'll have to use outdated syntax and specify place for every row manually. IE/Edge implementation doesn't have grid cell auto-placement. So if you don't specify
grid-column
/grid-row
for every cell they will all stack in very first cell. So for IE/Edge-ms-grid-row
and-ms-grid-column
default value is 1. Demo:If you want to test resizing here is jsFiddle.