Slide 1

Slide 1 text

CSS FLEXBOX Vladimír Kriška (@ujovlado) WebElement #35

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Classic “floats”

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Flexbox applied* *and minor improvements: styled button, changed image position

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Container, items, … source: http://www.w3.org/TR/css-flexbox-1/

Slide 9

Slide 9 text

flex-flow (shorthand) flex-direction • row, row-reverse, column, column-reverse • initial value: row flex-wrap • nowrap, wrap, wrap-reverse • initial value: nowrap • flex-direction || flex-wrap

Slide 10

Slide 10 text

order • • initial value: 0 • affects only visual media (not speech) • use it for visual, not logical ordering

Slide 11

Slide 11 text

Single-line & multi-line Once content is broken into lines, each line is independent

Slide 12

Slide 12 text

The “flex” property (shorthand) • none, [flex-grow && flex-shrink || flex-basis] • flex: none • 0 0 auto • flex: initial (this is an initial value) • 0 1 auto • flex: auto • 1 1 auto • flex: • 1 0% (e.g. flex: 10 => flex: 10 1 0%)

Slide 13

Slide 13 text

flex-grow & flex-shrink & flex-basis flex-grow how much the flex item will grow relative to the rest of the flex items flex-shrink how much the flex item will shrink relative to the rest of the flex items flex-basis initial main size of the flex item, before free space is distributed according to the flex factors

Slide 14

Slide 14 text

flex: 1 0 20%* *with min-width applied and disabled max-width min-width: 200px;

Slide 15

Slide 15 text

Different flex for each box* min-width: 200px; *with min-width applied and disabled max-width

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

justify-content • flex-start, flex-end, center, space-between, space-around • initial value: flex-start source: http://www.w3.org/TR/css-flexbox-1/

Slide 18

Slide 18 text

justify-content: center

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

align-items, align-self align-items • flex-start, flex-end, center, baseline, stretch • initial value: stretch • applies to: containers align-self • auto, flex-start, flex-end, center, baseline, stretch • initial value: auto • applies to: items

Slide 21

Slide 21 text

align-items, align-self source: http://www.w3.org/TR/css-flexbox-1/

Slide 22

Slide 22 text

So, how to center div vertically?

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

Questions? No?  Thank you!