SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen
by Jennifer Bland
Intro to Flexbox
with real world examples
Get the Code
h)ps://github.com/jenniferbland/intro-to-flexbox
CSS History
•Support for the box model
•Float images to right or leC of each other
•PosiEoning using Absolute and Fixed
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
Flexbox Benefits
•W3C Standard
•No libraries needed
•No longer need floats and clears
•Override source order with CSS
•Custom responsive layouts
Flexbox Support
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
Defining Flex Elements
•First define elements on page as Flex Containers
•In css add

display: flex;
Example_01
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
Flex-DirecEon
•Flex Container direcEon can be either row or column
•Defined by flex-direcEon
•Default is row
Example_02
Flex Container is Row
Flex Container is Column
Real Word Example - Calculator
•Using what we have earned about Flex Container 

and Flex Items we will start creaEng our calculator
Example_03a & b
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
flex-flow shorthand
•Shorthand for flex-direcEon and flex-wrap properEes
•Default is row nowrap
Example_05
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
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
Flex Basis
•Represents iniEal main size of a flex item before

free space is distributed
•Default value is 0
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
Real World Example - Calculator
•Using flex-grow, flex-shrink and flex-basis we can

finish styling on our calculator
Example_06
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
JusEfy Content
•Defines alignment along the main axis
•Distributes extra free space leC over
•Default: flex-start
JusEfy Content - row
Example_07
JusEfy Content - column
Example_08
Align Items
•Sets default behavior for how Flex Items are laid out

along the cross axis on the current line
•Default: stretch
Align Items
Align Content
•Aligns a Flex Container’s lines within when there is

extra space in the cross axis
•Default: stretch
Align Content
Real Word Examples
h)ps://github.com/jenniferbland/made-with-flexbox
NavigaEon
Center Image on Screen
Responsive Website Layout
Input Addon
3 Column Layout
h)p://www.jenniferbland.com
h)ps://github.com/jenniferbland/
jennifer@jenniferbland.com
@ratracegrad

Weitere ähnliche Inhalte

Ähnlich wie Intro to Flexbox with Real Word Examples

Basics of expression blend4
Basics of expression blend4Basics of expression blend4
Basics of expression blend4
Samson Tennela
 
CSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive DesignCSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive Design
Arash Milani
 

Ähnlich wie Intro to Flexbox with Real Word Examples (20)

CSS Flexbox and Grid Layouts
CSS Flexbox and Grid LayoutsCSS Flexbox and Grid Layouts
CSS Flexbox and Grid Layouts
 
Introduction to flexbox
Introduction  to  flexboxIntroduction  to  flexbox
Introduction to flexbox
 
MTA css layouts
MTA css layoutsMTA css layouts
MTA css layouts
 
Introduction to css flexbox
Introduction to css flexboxIntroduction to css flexbox
Introduction to css flexbox
 
#4 HTML & CSS [know-how]
#4 HTML & CSS [know-how]#4 HTML & CSS [know-how]
#4 HTML & CSS [know-how]
 
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
 
A complete guide to flexbox
A complete guide to flexboxA complete guide to flexbox
A complete guide to flexbox
 
Flexbox Will Shock You!
Flexbox Will Shock You!Flexbox Will Shock You!
Flexbox Will Shock You!
 
Flex Web Development.pdf
Flex Web Development.pdfFlex Web Development.pdf
Flex Web Development.pdf
 
css.pdf
css.pdfcss.pdf
css.pdf
 
Designing Windows apps with Xaml
Designing Windows apps with XamlDesigning Windows apps with Xaml
Designing Windows apps with Xaml
 
Cascading Style Sheets CSS
Cascading Style Sheets CSS Cascading Style Sheets CSS
Cascading Style Sheets CSS
 
Basics of expression blend4
Basics of expression blend4Basics of expression blend4
Basics of expression blend4
 
Understanding flexbox
Understanding flexboxUnderstanding flexbox
Understanding flexbox
 
digital swifton
digital swiftondigital swifton
digital swifton
 
Using Flexbox Today (Frontier Conf 2016)
Using Flexbox Today (Frontier Conf 2016)Using Flexbox Today (Frontier Conf 2016)
Using Flexbox Today (Frontier Conf 2016)
 
What The Flexbox? An Intro to Flexbox
What The Flexbox? An Intro to FlexboxWhat The Flexbox? An Intro to Flexbox
What The Flexbox? An Intro to Flexbox
 
CSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive DesignCSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive Design
 
Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)
 
Flexbox, Grid and Sass
Flexbox, Grid and SassFlexbox, Grid and Sass
Flexbox, Grid and Sass
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Intro to Flexbox with Real Word Examples