Skip to content

Instantly share code, notes, and snippets.

@filR
Last active January 9, 2017 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filR/7701865 to your computer and use it in GitHub Desktop.
Save filR/7701865 to your computer and use it in GitHub Desktop.
Flexbox attributes and values
Flex containers
Flex items
Main axis - size & direction
Cross axis - size & direction
Start & End
// <div class="container">
// <div/>
// <div/>
// <div/>
// </div>
// http://weblog.bocoup.com/dive-into-flexbox/
// http://css-tricks.com/snippets/css/a-guide-to-flexbox/
.container {
display: flex; // flex, inline-flex
flex-direction: row; // row*, row-reverse, column, column-reverse
// -- Distribution across axis
// main axis
justify-content: flex-start; // flex-start*, flex-end, center, space-between, space-around
// cross axis
align-items: stretch; // stretch*, flex-start, flex-end, center, baseline
// -- Overflow into multiple rows
flex-wrap: nowrap; // nowrap*, wrap, wrap-reverse
// cross axis alignment
align-content: stretch; // stretch*, flex-start, flex-end, center, space-between, space-around
}
// child properties
.container > div {
// when this item is rendered. render order vs src order.
order: 0; // e.g. -1, 1
margin: auto; // magic alignment
// override container's align-items
align-self: flex-start; // flex-start*, flex-end, center, baseline, stretch
// main axis sizing compared to others
flex: 0 1 auto; // grow (0-n), shrink (0-n), basis (width)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment