Created
September 28, 2017 15:42
-
-
Save boizz/957cd0757c489930cbc8278909298937 to your computer and use it in GitHub Desktop.
quick flex layout
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 { | |
display: -webkit-box; | |
display: -moz-box; | |
display: -ms-flexbox; | |
display: -webkit-flex; | |
display: flex; | |
} | |
/** | |
* 主轴对齐方向 box | |
* @params flex-start flex-end center space-between | |
*/ | |
@mixin justify-content ($justify) { | |
@if $justify == flex-start { | |
-webkit-box-pack: start; | |
} @else if $justify == flex-end { | |
-webkit-box-pack: end; | |
} @else if $justify == space-between { | |
-webkit-box-pack: justify; | |
} @else { | |
-webkit-box-pack: $justify; | |
} | |
-moz-justify-content: $justify; | |
-webkit-justify-content: $justify; | |
justify-content: $justify; | |
} | |
/** | |
* 交叉轴对齐方向 box | |
* @params flex-start flex-end center baseline stretch | |
*/ | |
@mixin align-items ($align) { | |
@if $align == flex-start { | |
-webkit-box-pack: start; | |
} @else if $align == flex-end { | |
-webkit-box-pack: end; | |
} @else { | |
-webkit-box-align: $align; | |
} | |
-moz-align-items: $align; | |
-webkit-align-items: $align; | |
align-items: $align; | |
} | |
/** | |
* 子元素的显示方向 box | |
* @params row row-reverse column column-reverse | |
*/ | |
@mixin flex-direction ($direction) { | |
@if $direction == row { | |
-webkit-box-direction: normal; | |
-webkit-box-orient: horizontal; | |
} @else if $direction == row-reverse { | |
-webkit-box-pack: end; | |
-webkit-box-direction: reverse; | |
-webkit-box-orient: horizontal; | |
} @else if $direction == column { | |
-webkit-box-direction: normal; | |
-webkit-box-orient: vertical; | |
} @else if $direction == column-reverse { | |
-webkit-box-pack: end; | |
-webkit-box-direction: reverse; | |
-webkit-box-orient: vertical; | |
} @else { | |
-webkit-box-align: $align; | |
} | |
-moz-flex-direction: $direction; | |
-webkit-flex-direction: $direction; | |
flex-direction: $direction; | |
} | |
/** | |
* 是否允许子元素伸缩 item | |
* @params {integer} | |
*/ | |
@mixin flex-grow ($grow) { | |
@if $grow == 0 { | |
-webkit-box-flex: 0.0; | |
} @else { | |
-webkit-box-flex: 1+$grow/10; | |
} | |
-moz-flex-grow: $grow; | |
-webkit-flex-grow: $grow; | |
flex-grow: $grow; | |
} | |
@mixin flex-shrink ($grow) { | |
@if $grow == 0 { | |
-webkit-box-flex: 0.0; | |
} @else { | |
-webkit-box-flex: 1+$grow/10; | |
} | |
-moz-flex-shrink: $grow; | |
-webkit-flex-shrink: $grow; | |
flex-shrink: $grow; | |
} | |
/** | |
* 子元素的显示次序 item | |
* @params {integer} | |
*/ | |
@mixin flex-order ($order) { | |
-webkit-box-ordinal-group: $order; | |
-moz-order: $order; | |
-webkit-order: $order; | |
order: $order; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问 -webkit-box-flex: 1+$grow/10; 这里计算的依据是什么呀