Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with...

36
Making Friends with Flexbox Sara Cope @sarassassin

Transcript of Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with...

Page 1: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Making Friends with Flexbox

Sara Cope@sarassassin

Page 2: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Hackpad: drupalgovcon2016.hackpad.com

#drupalgovcon

Page 3: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Starting with the basics

Page 4: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

What is flexbox?

Page 5: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Why you should care

Page 6: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

What flexbox is not

Page 7: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 8: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 9: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Properties for the container

Page 10: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

.container { display: flex; }

Page 11: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

.container { flex-direction: row | row-reverse column | column-reverse; }

flex-direction

Page 12: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

flex-wrap

.container { flex-wrap: wrap | nowrap | wrap-reverse; }

Page 13: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Getting started

1. Create your flex container with display: flex;

2. Set flex-direction to determine the layout of your items

3. Set flex-wrap to control if and how the items will wrap

Page 14: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 15: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

http://bit.ly/flexfun

Page 16: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 17: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

justify-content

.container { justify-content: flex-start | flex-end | center | space-between | space-around; }

Page 18: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

justify-content

Page 19: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 20: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

align-items

.container { align-items: flex-start | flex-end | center | stretch | baseline; }

Page 21: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 22: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 23: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Properties for the children

Page 24: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

flex-grow

.item { flex-grow: <number>; }

Page 25: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 26: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

order

.item { order: <number>; }

Page 27: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

order

Page 28: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 29: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

align-self

.item { align-self: flex-start | flex-end | center | baseline | stretch; }

Page 30: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Flexbox Tips

1. Embrace the flex and try to forget how you used to do it

2. If you’re not sure, start with little components. Use Chrome Inspector

3. Works best on page components not an entire layout

Page 32: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

Vendor Prefixing

Autoprefixer Sass Mixins

Page 33: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap
Page 34: Making Friends with Flexbox - Drupal GovConGetting started 1. Create your flex container with display: flex; 2. Set flex-direction to determine the layout of your items 3. Set flex-wrap

IE 10+