Created
October 31, 2016 22:15
-
-
Save moladukes/282afec694edaa4bfc54fa7951e83f88 to your computer and use it in GitHub Desktop.
Simple Flexbox grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gutter-width: 1rem; | |
$outer-margin: 2rem; | |
$gutter-compensation: -0.5rem; | |
$half-gutter-width: 0.5rem; | |
.row { | |
display: inline-block; | |
display: -ms-flexbox; | |
display: -webkit-flex; | |
display: flex; | |
*display: inline; | |
zoom: 1; | |
-ms-flex-wrap: wrap; | |
-webkit-flex-wrap: wrap; | |
flex-wrap: wrap; | |
padding: 0; | |
margin: 0; | |
position: relative; | |
list-style-type: none; | |
vertical-align: top; | |
justify-content: space-between; | |
margin-right: $gutter-compensation; | |
margin-left: $gutter-compensation; | |
} | |
.row:before, | |
.row:after { | |
letter-spacing: normal; | |
word-spacing: normal; | |
white-space: normal; | |
max-width: 100%; | |
} | |
.row *:before, | |
.row *:after { | |
letter-spacing: normal; | |
word-spacing: normal; | |
white-space: normal; | |
} | |
.row * { | |
vertical-align: middle; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
.row *:before, | |
.row *:after { | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
.row .item { | |
position: relative; | |
flex: 1 0 auto; | |
padding-right: $half-gutter-width; | |
padding-left: $half-gutter-width; | |
padding-top: $gutter-width; | |
} | |
.row .item-block { | |
flex: 1 0 auto; | |
img { | |
display: block; | |
width: 100%; | |
} | |
} | |
@media screen and (max-width: 580px) { | |
.item { | |
width: 100%; | |
*width: 99.9%; | |
} | |
} | |
@media screen and (min-width: 580px) { | |
.item-12 { | |
width: 100%; | |
*width: 99.9%; | |
} | |
.item-11 { | |
width: 91.66666667%; | |
*width: 91.56666667%; | |
} | |
.item-10 { | |
width: 83.33333333%; | |
*width: 83.23333333%; | |
} | |
.item-9 { | |
width: 75%; | |
*width: 74.9%; | |
} | |
.item-8 { | |
width: 66.66666667%; | |
*width: 66.56666667%; | |
} | |
.item-7 { | |
width: 58.33333333%; | |
*width: 58.23333333%; | |
} | |
.item-6 { | |
width: 50%; | |
*width: 49.9%; | |
} | |
.item-5 { | |
width: 41.66666667%; | |
*width: 41.56666667%; | |
} | |
.item-4 { | |
width: 33.33333333%; | |
*width: 33.23333333%; | |
} | |
.item-3 { | |
width: 25%; | |
*width: 24.9%; | |
} | |
.item-2 { | |
width: 16.66666667%; | |
*width: 16.56666667%; | |
} | |
.item-1 { | |
width: 8.33333333%; | |
*width: 8.23333333%; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment