-
-
Save MHM5000/95e32b720da28f805aa9cda3e14ae8f5 to your computer and use it in GitHub Desktop.
CSS3 Flexbox - LESS Mixins
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
| // See description: http://www.w3.org/TR/css3-flexbox | |
| // -------------------------------------------------- | |
| // flex or inline-flex | |
| .flex-display(@display: flex) { | |
| display: ~"-webkit-@{display}"; | |
| display: ~"-moz-@{display}"; | |
| display: ~"-ms-@{display}"; | |
| display: ~"-o-@{display}"; | |
| display: @display; | |
| } | |
| // <positive-number>, initial, auto, or none | |
| .flex(@columns: initial) { | |
| -webkit-flex: @columns; | |
| -moz-flex: @columns; | |
| -ms-flex: @columns; | |
| -o-flex: @columns; | |
| flex: @columns; | |
| } | |
| // row | row-reverse | column | column-reverse | |
| .flex-direction(@direction: row) { | |
| -webkit-flex-direction: @direction; | |
| -moz-flex-direction: @direction; | |
| -ms-flex-direction: @direction; | |
| -o-flex-direction: @direction; | |
| flex-direction: @direction; | |
| } | |
| // nowrap | wrap | wrap-reverse | |
| .flex-wrap(@wrap: nowrap) { | |
| -webkit-flex-wrap: @wrap; | |
| -moz-flex-wrap: @wrap; | |
| -ms-flex-wrap: @wrap; | |
| -o-flex-wrap: @wrap; | |
| flex-wrap: @wrap; | |
| } | |
| // <flex-direction> || <flex-wrap> | |
| .flex-flow(@flow) { | |
| -webkit-flex-flow: @flow; | |
| -moz-flex-flow: @flow; | |
| -ms-flex-flow: @flow; | |
| -o-flex-flow: @flow; | |
| flex-flow: @flow; | |
| } | |
| // <integer> | |
| .flex-order(@order: 0) { | |
| -webkit-order: @order; | |
| -moz-order: @order; | |
| -ms-order: @order; | |
| -o-order: @order; | |
| order: @order; | |
| } | |
| // <number> | |
| .flex-grow(@grow: 0) { | |
| -webkit-flex-grow: @grow; | |
| -moz-flex-grow: @grow; | |
| -ms-flex-grow: @grow; | |
| -o-flex-grow: @grow; | |
| flex-grow: @grow; | |
| } | |
| // <number> | |
| .flex-shrink(@shrink: 1) { | |
| -webkit-flex-shrink: @shrink; | |
| -moz-flex-shrink: @shrink; | |
| -ms-flex-shrink: @shrink; | |
| -o-flex-shrink: @shrink; | |
| flex-shrink: @shrink; | |
| } | |
| // <width> | |
| .flex-basis(@width: auto) { | |
| -webkit-flex-basis: @width; | |
| -moz-flex-basis: @width; | |
| -ms-flex-basis: @width; | |
| -o-flex-basis: @width; | |
| flex-basis: @width; | |
| } | |
| // flex-start | flex-end | center | space-between | space-around | |
| .justify-content(@justify: flex-start) { | |
| -webkit-justify-content: @justify; | |
| -moz-justify-content: @justify; | |
| -ms-justify-content: @justify; | |
| -o-justify-content: @justify; | |
| justify-content: @justify; | |
| } | |
| // flex-start | flex-end | center | space-between | space-around | stretch | |
| .align-content(@align: stretch) { | |
| -webkit-align-content: @align; | |
| -moz-align-content: @align; | |
| -ms-align-content: @align; | |
| -o-align-content: @align; | |
| align-content: @align; | |
| } | |
| // flex-start | flex-end | center | baseline | stretch | |
| .align-items(@align: stretch) { | |
| -webkit-align-items: @align; | |
| -moz-align-items: @align; | |
| -ms-align-items: @align; | |
| -o-align-items: @align; | |
| align-items: @align; | |
| } | |
| // auto | flex-start | flex-end | center | baseline | stretch | |
| .align-self(@align: auto) { | |
| -webkit-align-self: @align; | |
| -moz-align-self: @align; | |
| -ms-align-self: @align; | |
| -o-align-self: @align; | |
| align-self: @align; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like zurb foundation's approach in SASS.
You can
align(center,middle)with 1 command.