I have created a very basic flexbox layout with 12 columns. The problem which I'm facing is that my columns work only when I use a div container with class row. I'm not able to find out why it is working in that way. Can some one please help me or give an insight how to proceed.
My Code.
_variables.scss
// Grid Variables
$grid-columns: 12;
//Device-Breakpoints
$device-xs: 540px;
$device-sm: 768px;
$device-md: 992px;
$device-lg: 1200px;
_helpers.scss
@mixin border-box {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
grid.scss
@import "variables";
@import "helpers";
*.container {
@include border-box;
margin: 0 auto;
padding: 0 1em;
@media (min-width: $device-xs) {
max-width: $device-xs;
}
@media (min-width: $device-sm) {
max-width: $device-sm;
}
@media (min-width: $device-md) {
max-width: $device-md;
}
@media (min-width: $device-lg) {
max-width: $device-lg;
}
}
.row {
@include border-box;
display: flex;
flex-wrap: wrap;
margin-bottom: 1em;
}
@for $i from 1 through $grid-columns {
.col-xs-#{$i},
.col-sm-#{$i},
.col-md-#{$i},
.col-lg-#{$i} {
@include border-box;
padding: 1em;
width: 100%;
}
.col-xs-#{$i} {
@media (min-width: $device-xs) {
width: calc(100% * (#{$i} / 12));
}
}
.col-sm-#{$i} {
@media (min-width: $device-sm) {
width: calc(100% * (#{$i} / 12));
}
}
.col-md-#{$i} {
@media (min-width: $device-md) {
width: calc(100% * (#{$i} / 12));
}
}
.col-lg-#{$i} {
@media (min-width: $device-lg) {
width: calc(100% * (#{$i} / 12));
}
}
}