Skip to content

Instantly share code, notes, and snippets.

@justinav
Last active October 11, 2016 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save justinav/be54789f48a8d4a3e5fb to your computer and use it in GitHub Desktop.
Save justinav/be54789f48a8d4a3e5fb to your computer and use it in GitHub Desktop.
Flexbox Cheatsheet
/*
*
* Flex Box Cheatsheet
* ===================
*
*/
.flexbox {
display: flex;
flex-direction: row | column | row-reverse | column-reverse;
flex-wrap: wrap | nowrap;
justify-content: flex-start | flex-end | center | space-between | space-around;
align-items: stretch | flex-start | flex-end | center | baseline;
align-content: stretch | flex-start | flex-end | center | space-between | space-around;
}
.item{
flex: /* grow, shrink, basis */;
flex: 0 0 40px; /* fixed width */
flex: 0 1 auto; /* dynamic width */
flex: auto | initial | none | 1 0 33%;
order: 1;
flex-grow: 0;
flex-shrink: 1;
align-self: flex-start | flex-end | center | baseline | stretch;
}
/*
* Vertical Centering
*/
.flexbox {
display: flex;
}
.item {
margin: auto;
}
/*
* Prefixes
*/
.flexbox {
/* display */
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6, BB7 */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
display: flex; /* NEW, Spec - Firefox, Chrome, Opera */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
/* column direction */
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
/* row direction */
-webkit-box-orient: horizontal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
/* flex flow */
-webkit-flex-flow: row wrap;
-moz-flex-flow: row wrap;
-ms-flex-flow: row wrap;
-o-flex-flow: row wrap;
/* justify */
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
/* center justify */
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment