Created
October 14, 2015 01:23
-
-
Save philiprenich/7bad1f87a4dbc51debac to your computer and use it in GitHub Desktop.
Cross-browser compatible flexbox implementation
This file contains 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
@mixin flex-container($dir: row nowrap, $align: stretch) { | |
$ios_orient: horizontal; | |
$ios_lines: multiple; | |
@if nth($dir, 1) == column { | |
$ios_orient: vertical; | |
} | |
@if length($dir) > 1 and nth($dir, 2) == nowrap { | |
$ios_lines: single; | |
} | |
$ie10_dir: $dir; | |
$ie10_wrap: none; | |
@if length($dir) > 1 { | |
$ie10_dir: nth($dir, 1); | |
$ie10_wrap: nth($dir, 2); | |
} | |
display: -webkit-box; //ios | |
display: -webkit-flex; | |
display: -moz-flex; | |
display: -ms-flexbox; | |
display: flex; | |
-webkit-flex-flow: $dir; | |
-moz-flex-flow: $dir; | |
-ms-flex-direction: $ie10_dir; | |
-ms-flex-wrap: $ie10_wrap; | |
-webkit-box-orient: $ios_orient; //ios | |
-webkit-box-lines: $ios_lines; //ios | |
flex-flow: $dir; | |
-webkit-align-items: $align; | |
-moz-align-items: $align; | |
-ms-flex-align: $align; | |
-webkit-box-align: $align; //ios | |
align-items: $align; | |
} | |
@mixin justify($justify: flex-start) { | |
$old: $justify; | |
@if $justify == space-between { | |
$old: justify; | |
} | |
@if $justify == flex-start { | |
$old: start; | |
} | |
@if $justify == flex-end { | |
$old: end; | |
} | |
flex-pack: $old; | |
-ms-flex-pack: $old; | |
-webkit-justify-content: $justify; | |
justify-content: $justify; | |
} | |
@mixin flex-item($flex: 0 1 auto) { | |
$ios_flex: nth($flex, 1); | |
-webkit-box-flex: $ios_flex; //ios | |
-webkit-flex: $flex; | |
-moz-flex: $flex; | |
-ms-flex: $flex; | |
flex: $flex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment