If you hate floats, you will love flexbox. If you hate media queries, you will love Flexbox. Flexbox gives you more control in creating a responsive layout than the traditional box model. In this session I will introduce you to Flexbox by showing how to use it to solve common website problems. You will learn how easy it is to implement Flexbox into your existing website design.
3. CSS History
•Support for the box model
•Float images to right or leC of each other
•PosiEoning using Absolute and Fixed
4. Why Flexbox?
•One of several new CSS layout models
•Designed to make craCing CSS layouts easy
•Allows you to control alignment, spacing and
sizing of elements relaEve to their parents
5. Flexbox Benefits
•W3C Standard
•No libraries needed
•No longer need floats and clears
•Override source order with CSS
•Custom responsive layouts
7. Using Flexbox
•Define a parent element as a Flex Container
•All child elements become Flex Items
•Flexbox properEes can then control orientaEon,
alignment, size and spacing of child Flex Items
•Flex Containers are set to either row or column
orientaEon
9. Understanding Flex Axis
•Flexbox has a main axis and a cross axis which
control the distribuEon and layout of elements
• main axis - is the axis along which the flex items
follow each other
• cross axis - axis perpendicular to the main axis
13. Real Word Example - Calculator
•Using what we have earned about Flex Container
and Flex Items we will start creaEng our calculator
Example_03a & b
14. Content Wrapping
•By default all Flexbox Containers are single lined
•Size, align and space Flex Items along that single line
•Use flex-wrap property to get Flex Items to wrap
to a new line
•Default value is nowrap
Example_04
16. Flex Grow
•Represents how much the flex item will grow relaEve
to the rest of the flex items in the container once
posiEve space has been distributed
•Default value is 0
17. Flex Shrink
•Represents how much the flex item will shrink
relaEve to the rest of the flex items in the container
once negaEve space has been distributed
•Default value is 1
19. Flex Property
•Flex Grow
•Flex Shrink
•Flex Basis
•These properEes are used to define flex item size in
relaEon to other flex items and how to grow or shrink
20. Real World Example - Calculator
•Using flex-grow, flex-shrink and flex-basis we can
finish styling on our calculator
Example_06
21. Controlling Alignment
•Flex Container has two axis - main axis and cross axis
•There are controls for controlling alignment on either
main axis or cross axis