I have an HTML problem that is pretty tricky and I\'m not sure there is a CSS-based solution for it. Basically I have a three column grid. The first and third columns can contai
If you don't mind only working in a small handful of browsers, then you can absolutely do this with pure CSS. Go ahead, add and remove as many grandchild divs as you want:
http://codepen.io/cimmanon/pen/ldmtJ
/* line 5, ../sass/test.scss */
.wrapper {
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
}
@supports (display: flex) and (flex-wrap: wrap) {
/* line 5, ../sass/test.scss */
.wrapper {
display: flex;
}
}
/* line 9, ../sass/test.scss */
.a, .b, .c {
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
@supports (display: flex) and (flex-wrap: wrap) {
/* line 9, ../sass/test.scss */
.a, .b, .c {
display: flex;
}
}
/* line 13, ../sass/test.scss */
.a div, .b div, .c div {
border: 1px solid;
-webkit-flex: 1 0 100%;
-ms-flex: 1 0 100%;
flex: 1 0 100%;
}
/* Fancy it up! */
/* line 21, ../sass/test.scss */
.a {
background: #ff9999;
-webkit-flex: 1 1 10em;
-ms-flex: 1 1 10em;
flex: 1 1 10em;
}
/* line 26, ../sass/test.scss */
.b {
background: #00e600;
-webkit-flex: 1 1 10em;
-ms-flex: 1 1 10em;
flex: 1 1 10em;
}
/* line 31, ../sass/test.scss */
.c {
background: #9999ff;
-webkit-flex: 1 1 40%;
-ms-flex: 1 1 40%;
flex: 1 1 40%;
}
a
a
a
a
a
b
c
c
Browser support: Opera, Chrome, IE10. When Firefox finally gets around to finishing supporting the current Flexbox draft including flex-wrap, then it will work there as well.