Last active
August 29, 2015 14:22
-
-
Save guillaumevincent/6e89ec0d6aaa51733dcf to your computer and use it in GitHub Desktop.
Flexbox simple 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
$container-width : 1140px; | |
$gutter : 1em; | |
$small-screen : 768px; // screens between 481px and 768px | |
$medium-screen : 1024px; // screens between 769px and 1024px | |
*, *:before, *:after { | |
box-sizing: border-box | |
} | |
html, body { | |
margin: 0; | |
padding: 0; | |
} | |
.container { | |
margin: 0 auto; | |
max-width: $container-width; | |
width: 100%; | |
} | |
.row { | |
display: flex; | |
flex-wrap: wrap; | |
.col { | |
padding: $gutter; | |
flex-grow: 1; | |
flex-shrink: 1; | |
flex-basis: 100%; | |
} | |
.row { | |
margin: -$gutter; | |
} | |
@media (min-width: $medium-screen) { | |
@for $i from 1 through 11 { | |
.w#{$i} { | |
flex: $i 0 0 !important; | |
} | |
} | |
} | |
@media (min-width: $small-screen) { | |
@for $i from 1 through 11 { | |
.m#{$i} { | |
flex: $i 0 0; | |
} | |
} | |
} | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head lang="fr"> | |
<meta charset="UTF-8"> | |
<title>flexbox grid</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="style.css" media="all"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col w6"> | |
.col .w6 | |
</div> | |
<div class="col w3"> | |
<div class="row"> | |
<div class="col w2 m4"> | |
.col .w2 .m4 | |
</div> | |
<div class="col w2 m4"> | |
.col .w2 .m4 | |
</div> | |
<div class="col w8 m4"> | |
.col .w2 .m4 | |
</div> | |
</div> | |
</div> | |
<div class="col w3"> | |
.col .w3 | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
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
*,:after,:before{box-sizing:border-box}body,html{margin:0;padding:0}.container{margin:0 auto;max-width:1140px;width:100%}.row{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:wrap;-ms-flex-wrap:wrap;flex-wrap:wrap}.row .col{padding:1em;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;-webkit-flex-basis:100%;-ms-flex-preferred-size:100%;flex-basis:100%}.row .row{margin:-1em}@media (min-width:1024px){.row .w1{-webkit-box-flex:1!important;-webkit-flex:1 0 0!important;-ms-flex:1 0 0!important;flex:1 0 0!important}.row .w2{-webkit-box-flex:2!important;-webkit-flex:2 0 0!important;-ms-flex:2 0 0!important;flex:2 0 0!important}.row .w3{-webkit-box-flex:3!important;-webkit-flex:3 0 0!important;-ms-flex:3 0 0!important;flex:3 0 0!important}.row .w4{-webkit-box-flex:4!important;-webkit-flex:4 0 0!important;-ms-flex:4 0 0!important;flex:4 0 0!important}.row .w5{-webkit-box-flex:5!important;-webkit-flex:5 0 0!important;-ms-flex:5 0 0!important;flex:5 0 0!important}.row .w6{-webkit-box-flex:6!important;-webkit-flex:6 0 0!important;-ms-flex:6 0 0!important;flex:6 0 0!important}.row .w7{-webkit-box-flex:7!important;-webkit-flex:7 0 0!important;-ms-flex:7 0 0!important;flex:7 0 0!important}.row .w8{-webkit-box-flex:8!important;-webkit-flex:8 0 0!important;-ms-flex:8 0 0!important;flex:8 0 0!important}.row .w9{-webkit-box-flex:9!important;-webkit-flex:9 0 0!important;-ms-flex:9 0 0!important;flex:9 0 0!important}.row .w10{-webkit-box-flex:10!important;-webkit-flex:10 0 0!important;-ms-flex:10 0 0!important;flex:10 0 0!important}.row .w11{-webkit-box-flex:11!important;-webkit-flex:11 0 0!important;-ms-flex:11 0 0!important;flex:11 0 0!important}}@media (min-width:768px){.row .m1{-webkit-box-flex:1;-webkit-flex:1 0 0;-ms-flex:1 0 0;flex:1 0 0}.row .m2{-webkit-box-flex:2;-webkit-flex:2 0 0;-ms-flex:2 0 0;flex:2 0 0}.row .m3{-webkit-box-flex:3;-webkit-flex:3 0 0;-ms-flex:3 0 0;flex:3 0 0}.row .m4{-webkit-box-flex:4;-webkit-flex:4 0 0;-ms-flex:4 0 0;flex:4 0 0}.row .m5{-webkit-box-flex:5;-webkit-flex:5 0 0;-ms-flex:5 0 0;flex:5 0 0}.row .m6{-webkit-box-flex:6;-webkit-flex:6 0 0;-ms-flex:6 0 0;flex:6 0 0}.row .m7{-webkit-box-flex:7;-webkit-flex:7 0 0;-ms-flex:7 0 0;flex:7 0 0}.row .m8{-webkit-box-flex:8;-webkit-flex:8 0 0;-ms-flex:8 0 0;flex:8 0 0}.row .m9{-webkit-box-flex:9;-webkit-flex:9 0 0;-ms-flex:9 0 0;flex:9 0 0}.row .m10{-webkit-box-flex:10;-webkit-flex:10 0 0;-ms-flex:10 0 0;flex:10 0 0}.row .m11{-webkit-box-flex:11;-webkit-flex:11 0 0;-ms-flex:11 0 0;flex:11 0 0}} |
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
*, :after, :before { | |
box-sizing: border-box | |
} | |
body, html { | |
margin: 0; | |
padding: 0 | |
} | |
.container { | |
margin: 0 auto; | |
max-width: 1140px; | |
width: 100% | |
} | |
.row { | |
display: flex; | |
flex-wrap: wrap | |
} | |
.row .col { | |
padding: 1em; | |
flex-grow: 1; | |
flex-shrink: 1; | |
flex-basis: 100% | |
} | |
.row .row { | |
margin: -1em | |
} | |
@media (min-width: 1024px) { | |
.row .w1 { | |
flex: 1 0 0 !important | |
} | |
.row .w2 { | |
flex: 2 0 0 !important | |
} | |
.row .w3 { | |
flex: 3 0 0 !important | |
} | |
.row .w4 { | |
flex: 4 0 0 !important | |
} | |
.row .w5 { | |
flex: 5 0 0 !important | |
} | |
.row .w6 { | |
flex: 6 0 0 !important | |
} | |
.row .w7 { | |
flex: 7 0 0 !important | |
} | |
.row .w8 { | |
flex: 8 0 0 !important | |
} | |
.row .w9 { | |
flex: 9 0 0 !important | |
} | |
.row .w10 { | |
flex: 10 0 0 !important | |
} | |
.row .w11 { | |
flex: 11 0 0 !important | |
} | |
} | |
@media (min-width: 768px) { | |
.row .m1 { | |
flex: 1 0 0 | |
} | |
.row .m2 { | |
flex: 2 0 0 | |
} | |
.row .m3 { | |
flex: 3 0 0 | |
} | |
.row .m4 { | |
flex: 4 0 0 | |
} | |
.row .m5 { | |
flex: 5 0 0 | |
} | |
.row .m6 { | |
flex: 6 0 0 | |
} | |
.row .m7 { | |
flex: 7 0 0 | |
} | |
.row .m8 { | |
flex: 8 0 0 | |
} | |
.row .m9 { | |
flex: 9 0 0 | |
} | |
.row .m10 { | |
flex: 10 0 0 | |
} | |
.row .m11 { | |
flex: 11 0 0 | |
} | |
} |
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
*,:after,:before{box-sizing:border-box}body,html{margin:0;padding:0}.container{margin:0 auto;max-width:1140px;width:100%}.row{display:flex;flex-wrap:wrap}.row .col{padding:1em;flex-grow:1;flex-shrink:1;flex-basis:100%}.row .row{margin:-1em}@media (min-width:1024px){.row .w1{flex:1 0 0!important}.row .w2{flex:2 0 0!important}.row .w3{flex:3 0 0!important}.row .w4{flex:4 0 0!important}.row .w5{flex:5 0 0!important}.row .w6{flex:6 0 0!important}.row .w7{flex:7 0 0!important}.row .w8{flex:8 0 0!important}.row .w9{flex:9 0 0!important}.row .w10{flex:10 0 0!important}.row .w11{flex:11 0 0!important}}@media (min-width:768px){.row .m1{flex:1 0 0}.row .m2{flex:2 0 0}.row .m3{flex:3 0 0}.row .m4{flex:4 0 0}.row .m5{flex:5 0 0}.row .m6{flex:6 0 0}.row .m7{flex:7 0 0}.row .m8{flex:8 0 0}.row .m9{flex:9 0 0}.row .m10{flex:10 0 0}.row .m11{flex:11 0 0}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment