Top Banner
swaggy layouts with flexbox
129

Swaggy Layouts With Flexbox

Jan 09, 2017

Download

Internet

FITC
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Swaggy Layouts With Flexbox

swaggy layouts with flexbox

Page 2: Swaggy Layouts With Flexbox

i’m haris.@harismahmood89

meetharis.com

Page 3: Swaggy Layouts With Flexbox

i’m haris.I’m a developer at TWG

Page 4: Swaggy Layouts With Flexbox

i’m haris.I’m a content lead at Ladies Learning Code

Page 5: Swaggy Layouts With Flexbox

i’m haris.I’m an instructor at HackerYou

Page 6: Swaggy Layouts With Flexbox

i get excited

Page 7: Swaggy Layouts With Flexbox

i swear

Page 8: Swaggy Layouts With Flexbox

i swear a lot

Page 9: Swaggy Layouts With Flexbox

i swear a lot

Page 10: Swaggy Layouts With Flexbox

emma watson

Page 11: Swaggy Layouts With Flexbox

• where we were

• where we are today

• limitations

• the swag that is flexbox

• examples

Page 12: Swaggy Layouts With Flexbox

Tim Berners-Lee 1980

Page 13: Swaggy Layouts With Flexbox

-9

Page 14: Swaggy Layouts With Flexbox

hella stoked

Page 15: Swaggy Layouts With Flexbox

Tim Berners-Lee 1990

Page 16: Swaggy Layouts With Flexbox

CSS 1996

Page 17: Swaggy Layouts With Flexbox

aw snap.

Page 18: Swaggy Layouts With Flexbox

hot damn.

Page 19: Swaggy Layouts With Flexbox

2015

Page 20: Swaggy Layouts With Flexbox

we’ve come a long way

Page 21: Swaggy Layouts With Flexbox

layouts

Page 22: Swaggy Layouts With Flexbox

originally built using tables

Page 23: Swaggy Layouts With Flexbox

then came floats

Page 24: Swaggy Layouts With Flexbox

then came inline-block

Page 25: Swaggy Layouts With Flexbox

“layouts are hard”

Page 26: Swaggy Layouts With Flexbox

layouts are tricky

Page 27: Swaggy Layouts With Flexbox

layouts are trickymainly because our current way of implementing layouts are all hacks

Page 28: Swaggy Layouts With Flexbox

floats and inline-block were not designed to create layouts

Page 29: Swaggy Layouts With Flexbox

limitations still exist

Page 30: Swaggy Layouts With Flexbox

examples of yucky-ness

Page 31: Swaggy Layouts With Flexbox

vertical centering

Page 32: Swaggy Layouts With Flexbox
Page 33: Swaggy Layouts With Flexbox

sticky footers

Page 34: Swaggy Layouts With Flexbox
Page 35: Swaggy Layouts With Flexbox

the holy grail layout

Page 36: Swaggy Layouts With Flexbox

fixed height 100% width

fixed height 100% width

fixed width 100% height

fixed width 100% height

100% width 100% height

notes footer should ‘stick’ to the bottom when not enough content is present

the centre column should appear first in the markup

Page 37: Swaggy Layouts With Flexbox

these are just some of the issues that developers face

Page 38: Swaggy Layouts With Flexbox
Page 39: Swaggy Layouts With Flexbox

enter flexbox

Page 40: Swaggy Layouts With Flexbox

The flexbox layout module was created to help build

efficient layouts

Page 41: Swaggy Layouts With Flexbox

more complex

Page 42: Swaggy Layouts With Flexbox

more flex-ible

Page 43: Swaggy Layouts With Flexbox

less hacky

Page 44: Swaggy Layouts With Flexbox
Page 45: Swaggy Layouts With Flexbox

can i have browser support?

Page 46: Swaggy Layouts With Flexbox

sorta. ish. yeah.

Page 47: Swaggy Layouts With Flexbox

https://philipwalton.github.io/solved-by-flexbox/

Page 48: Swaggy Layouts With Flexbox
Page 49: Swaggy Layouts With Flexbox
Page 50: Swaggy Layouts With Flexbox

the globe and mail

Page 51: Swaggy Layouts With Flexbox
Page 52: Swaggy Layouts With Flexbox
Page 53: Swaggy Layouts With Flexbox

property definition

Page 54: Swaggy Layouts With Flexbox

2009

Page 55: Swaggy Layouts With Flexbox

box-

Page 56: Swaggy Layouts With Flexbox

display: flexbox

Page 57: Swaggy Layouts With Flexbox

display: flex

Page 58: Swaggy Layouts With Flexbox

display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;-webkit-box-pack: justify;-webkit-justify-content: space-between;-ms-flex-pack: justify;justify-content: space-between;-webkit-box-align: center;-webkit-align-items: center;-ms-flex-align: center;align-items: center;-webkit-flex-wrap: wrap;-ms-flex-wrap: wrap;flex-wrap: wrap;

Page 59: Swaggy Layouts With Flexbox

autoprefixer

Page 60: Swaggy Layouts With Flexbox

lack of support beyond browsers

Page 61: Swaggy Layouts With Flexbox

scrollmagic

Page 62: Swaggy Layouts With Flexbox

4 initial concepts

Page 63: Swaggy Layouts With Flexbox

flex container

Page 64: Swaggy Layouts With Flexbox

flex items(or flex children)

Page 65: Swaggy Layouts With Flexbox

main axis

Page 66: Swaggy Layouts With Flexbox

cross axis

Page 67: Swaggy Layouts With Flexbox

you will either apply CSS to the container, or the items

Page 68: Swaggy Layouts With Flexbox

display: flex;

this is the magic.

flex container

Page 69: Swaggy Layouts With Flexbox
Page 70: Swaggy Layouts With Flexbox

flex-direction

control the direction of flow for the flex items sets the main axis

flex container

Page 71: Swaggy Layouts With Flexbox

flex-direction: row;1 2 3

Page 72: Swaggy Layouts With Flexbox

flex-direction: row-reverse;3 2 1

Page 73: Swaggy Layouts With Flexbox

flex-direction: column;

1

2

3

Page 74: Swaggy Layouts With Flexbox

flex-direction: column-reverse;

3

2

1

Page 75: Swaggy Layouts With Flexbox

justify-content

control how flex items should justify/align on the main axis

flex container

Page 76: Swaggy Layouts With Flexbox

justify-content: flex-start;

Page 77: Swaggy Layouts With Flexbox

justify-content: flex-end;

Page 78: Swaggy Layouts With Flexbox

justify-content: center;

Page 79: Swaggy Layouts With Flexbox

justify-content: space-between;

Page 80: Swaggy Layouts With Flexbox

justify-content: space-around;

Page 81: Swaggy Layouts With Flexbox

flex-wrap

control item behaviour when adjusting viewport size

flex container

Page 82: Swaggy Layouts With Flexbox

flex-wrap: nowrap;

Page 83: Swaggy Layouts With Flexbox

flex-wrap: wrap;

Page 84: Swaggy Layouts With Flexbox

flex-wrap: wrap-reverse;

Page 85: Swaggy Layouts With Flexbox

align-items

control item layout on cross axis

flex container

Page 86: Swaggy Layouts With Flexbox

align-items: stretch;

Page 87: Swaggy Layouts With Flexbox

align-items: flex-start;

Page 88: Swaggy Layouts With Flexbox

align-items: flex-end;

Page 89: Swaggy Layouts With Flexbox

align-items: center;

Page 90: Swaggy Layouts With Flexbox

align-content

control alignment for multiple lines of items

flex container

Page 91: Swaggy Layouts With Flexbox

align-content: stretch;

Page 92: Swaggy Layouts With Flexbox

align-content: flex-start;

Page 93: Swaggy Layouts With Flexbox

align-content: flex-end;

Page 94: Swaggy Layouts With Flexbox

align-content: center;

Page 95: Swaggy Layouts With Flexbox

align-content: space-between;

Page 96: Swaggy Layouts With Flexbox

align-content: space-around;

Page 97: Swaggy Layouts With Flexbox

order

control the sequence of items

flex item

Page 98: Swaggy Layouts With Flexbox

order: x;-1 1 1 2 3

Page 99: Swaggy Layouts With Flexbox

align-self

control a single item’s alignment

flex item

Page 100: Swaggy Layouts With Flexbox

align-self: flex-start;

Page 101: Swaggy Layouts With Flexbox

align-self: flex-end;

Page 102: Swaggy Layouts With Flexbox

align-self: center;

Page 103: Swaggy Layouts With Flexbox

align-self: stretch;

Page 104: Swaggy Layouts With Flexbox

flex-grow

control an item’s ability to grow if necessary

flex item

Page 105: Swaggy Layouts With Flexbox

flex-grow: x;1 1 2 1

Page 106: Swaggy Layouts With Flexbox

flex-shrink

control an item’s ability to shrink if necessary

flex item

Page 107: Swaggy Layouts With Flexbox

flex-basis

control an item’s default size before remaining space is distributed

flex item

Page 108: Swaggy Layouts With Flexbox

flex

short-hand for flex-grow, flex-shrink and flex-basis

flex item

Page 109: Swaggy Layouts With Flexbox

flex: <grow> <shrink> <basis>;

Page 110: Swaggy Layouts With Flexbox

flex: 1 0 auto;

Page 111: Swaggy Layouts With Flexbox

flex: 1;

Page 112: Swaggy Layouts With Flexbox

• https://css-tricks.com/snippets/css/a-guide-to-flexbox

• http://jonibologna.com/content/images/flexboxsheet.pdf

• What The Flexbox: http://flexbox.io

Page 113: Swaggy Layouts With Flexbox

examples

Page 114: Swaggy Layouts With Flexbox

the future looks fantastic

Page 115: Swaggy Layouts With Flexbox

adobe

Page 116: Swaggy Layouts With Flexbox
Page 117: Swaggy Layouts With Flexbox

mobile apps w/ web views

Page 118: Swaggy Layouts With Flexbox

so.

Page 119: Swaggy Layouts With Flexbox

“I don’t want to learn anything new”

Page 120: Swaggy Layouts With Flexbox

emma would be disappointed

Page 121: Swaggy Layouts With Flexbox

“I manage fine without it”

Page 122: Swaggy Layouts With Flexbox

new tools

Page 123: Swaggy Layouts With Flexbox

new learnings

Page 124: Swaggy Layouts With Flexbox

new potential

Page 125: Swaggy Layouts With Flexbox

new ideas

Page 126: Swaggy Layouts With Flexbox

new boundaries to push

Page 127: Swaggy Layouts With Flexbox

more magic

Page 128: Swaggy Layouts With Flexbox

hopefully more emma

Page 129: Swaggy Layouts With Flexbox

thank-you#OneLove

@harismahmood89