ABOUT
FLEXBOX
You can't float anymore
MILANO FRONT END MEETUP - 15/12/2015
About me
I'm Davide Di Pumpo and I'm a front-end developer.
I love graphic novel, competitive videogames and cats.
You can find me on the internet with the nickname
MakhBeth
- -Twitter GitHub LinkedIn
Let's start
MEOW
The problem?
How can I make this f*****g layout?
The holy grail layout
The Holy Grail refers to a web page layout which has multiple, equal height
columns that are defined with style sheets. It is commonly desired and
implemented, although the ways in which it can be implemented with current
technologies all have drawbacks. Because of this, finding an optimal
implementation has been likened to searching for the elusive Holy Grail.
Source - Wikipedia
Once upon a time...
...we had:
Tables
Inline block
Float
Tables
Seriously?
Semantic? NOPE
Responsive? NOPE
Vertical align? YUP
Order? NOPE *
How about
display:table;?
Semantic? YUP *
Responsive? YUP *
Vertical align? YUP *
Order? NOPE *
Come on! What's the problem guy?
You must use element to simulate row
Styling the element is a pain.
Try to add a padding to a row
or a max-width to a cell
The order is still a view issue
Try it yourself
Inline Block
Semantic? YUP
Responsive? YUP *
Vertical align? ALMOST
Order? NOPE *
What's the matter?
Vertical stretch an element is impossible
but...
BUT...
White Space
Float
Semantic? YUP
Responsive? YUP *
Vertical align? AHAHAHAHAH NOPE
Order? NOPE *
Why not?
Clearfix
Block Formatting Context
Impossible to manage vertical alignment
The holy grail
RECAP
about the old good times
Tables have issues
Inline blocks have issues
Floats have issues
It's impossible (without hacks) to manage order
more important...
They are all hacks
Why Flexbox?
Semantic? YUP
Responsive? YUP
Vertical align? YUP
Order? F*CK YEAH
The holy grail
SEE IT IN ACTION
It's all there?
Nope
But first some important knowledge
Differences between container and item
display: flex;
Flex item Flex item Flex item
Direction
------ direction row ------>
Flex item Flex item Flex item
C
o
l
u
m
n
Flex item
Flex item
Flex item
Flex Basis, all is relative
flex-basis: 50%; flex-basis: 50%;
flex-basis: 50%;
flex-basis: 50%;
Let's see all the rules!
Responsive without media query!
You can use flex basis to manage a min-dimension
EXAMPLE
Mix it with the old school!
You can starting use flex via beautiful enhancement!
EXAMPLE
But you can use media
query for beautiful thing
With order property!
EXAMPLE
RECAP
Flexible
Responsive
Ready for today
What's now?
Can I use?
How about old crappy explorer?
Don't worry:
A polyfill appears!
Is flexbox a
silver bullet?
No
Sorry, I've lied to you
A little
Flexbox is designed basically for:
content driven layout
component
not for grid
Take a look at css grid
But Grid CSS is not supported for
now
Any idea?
There are a few:
And my favourite one...
Flexboxgrid
Bootstrap - alpha 4
Super GiGi
RECAP
Can I use? Yes
It's not for everything, but is the best we have now
There are a lot of tool to help us.
Links for you:
CSS Tricks guide to flexbox
Learn flexbox playing with flexbox froggy
All the known flexbox bugs
Autoprefixer
Questions?

Understanding flexbox