Skip to content

Instantly share code, notes, and snippets.

@MHM5000
Forked from jayj/flexbox.less
Last active September 26, 2017 12:43
Show Gist options
  • Save MHM5000/95e32b720da28f805aa9cda3e14ae8f5 to your computer and use it in GitHub Desktop.
Save MHM5000/95e32b720da28f805aa9cda3e14ae8f5 to your computer and use it in GitHub Desktop.
CSS3 Flexbox - LESS Mixins
.flex-display(@display: flex) {
display: @display;
}
.flex(@columns: initial) {
flex: @columns;
}
.flex-direction(@direction: row) {
flex-direction: @direction;
}
.flex-wrap(@wrap: nowrap) {
flex-wrap: @wrap;
}
.flex-flow(@flow) {
flex-flow: @flow;
}
.flex-order(@order: 0) {
order: @order;
}
.flex-grow(@grow: 0) {
flex-grow: @grow;
}
.flex-shrink(@shrink: 1) {
flex-shrink: @shrink;
}
.flex-basis(@width: auto) {
flex-basis: @width;
}
.justify-content(@justify: flex-start) {
justify-content: @justify;
}
.align-content(@align: stretch) {
align-content: @align;
}
.align-items(@align: stretch) {
align-items: @align;
}
.align-self(@align: auto) {
align-self: @align;
}
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Use Autoprefixer for Browser Compatibility
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: @display;
}
// The 'flex' shorthand
// - applies to: flex items
// <positive-number>, initial, auto, or none
.flex(@columns: initial) {
flex: @columns;
}
// Flex Flow Direction
// - applies to: flex containers
// row | row-reverse | column | column-reverse
.flex-direction(@direction: row) {
flex-direction: @direction;
}
// Flex Line Wrapping
// - applies to: flex containers
// nowrap | wrap | wrap-reverse
.flex-wrap(@wrap: nowrap) {
flex-wrap: @wrap;
}
// Flex Direction and Wrap
// - applies to: flex containers
// <flex-direction> || <flex-wrap>
.flex-flow(@flow) {
flex-flow: @flow;
}
// Display Order
// - applies to: flex items
// <integer>
.flex-order(@order: 0) {
order: @order;
}
// Flex grow factor
// - applies to: flex items
// <number>
.flex-grow(@grow: 0) {
flex-grow: @grow;
}
// Flex shrink
// - applies to: flex item shrink factor
// <number>
.flex-shrink(@shrink: 1) {
flex-shrink: @shrink;
}
// Flex basis
// - the initial main size of the flex item
// - applies to: flex itemsnitial main size of the flex item
// <width>
.flex-basis(@width: auto) {
flex-basis: @width;
}
// Axis Alignment
// - applies to: flex containers
// flex-start | flex-end | center | space-between | space-around
.justify-content(@justify: flex-start) {
justify-content: @justify;
}
// Packing Flex Lines
// - applies to: multi-line flex containers
// flex-start | flex-end | center | space-between | space-around | stretch
.align-content(@align: stretch) {
align-content: @align;
}
// Cross-axis Alignment
// - applies to: flex containers
// flex-start | flex-end | center | baseline | stretch
.align-items(@align: stretch) {
align-items: @align;
}
// Cross-axis Alignment
// - applies to: flex items
// auto | flex-start | flex-end | center | baseline | stretch
.align-self(@align: auto) {
align-self: @align;
}
@MHM5000
Copy link
Author

MHM5000 commented Sep 26, 2017

I like zurb foundation's approach in SASS.

You can align(center,middle) with 1 command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment