SlideShare a Scribd company logo
7
Most read
15
Most read
17
Most read
Flexbox
(Flexible Box Layout)
The CSS3 Flexible Box, or flexbox, is a
layout mode providing for the arrangement
of elements on a page such that the
elements behave predictably when the page
layout must accommodate different screen
sizes and different display devices.
Mozilla Developer Network
What is Flexbox?
Designed to provide a better way to lay out, align, and
distribute space among items in a container - even when
dynamic.
Flexbox is a CSS layout mode designed to ensure that
elements behave predictably in different screen sizes and
devices. … it creates Intelligent boxes.
Easily Defined in CSS and markup (incl. media queries).
Directionally agnostic. (block = vertically-based & inline
= horizontally-based)
Best used for smaller modules over broader layout
“Old” and “New” syntax
Oddly, the syntax has changed since initial conception -
which has resulted in common references to “old” and “new”
versions.
Weaving together the two, (and in-betweens) provides decent
browser support - especially for order-controlled grids
▪ Chris Coyier (2013)
Requires additional code and prefixed code when authoring
for best results. … consider a js library (autoprefixer)
Examples
NEW: display: flex;
TWEEN: display; -ms-flexbox;
OLD: display: box;
Core Concepts
Flexbox consists of:
▪Flex Containers
▪Flex Items
Flex Container
Declared on an element using the display property
display: flex or display: inline-flex
Flex Item
Flex items are positioned inside of a flex container along
a “flex line”. By default 1 flex line per flex container.
contaner
< items
Core Concepts
Flex Line (axis, rope)
Flex items are laid out in a single “line” (default) or on
several “lines” according to the flex-wrap property. No
longer think about top-to-bottom or left-to-right. Abandon
rows/columns thinking.
direction orientation
Core Concepts
Flex Line
In addition to Alignment, Orientation and Direction, flex
lines can be reordered! This is huge. We can now
structure our HTML for semantics, accessibility, and SEO
.item { order: <integer>; }
order
By default, flex
items are laid
out in source
order
Core Concepts
Nested Flex Lines
Each flexbox layout (box) can contain another set that is
on their own line.
Nested flexboxes
Core Concepts
flex-wrap
By default all flex items will try to fit together into one
line. This can be changed and direction can be modified
using the flex-wrap property.
.container {
flex-wrap: wrap; nowrap | wrap | wrap reverse
}
Core Concepts
flex-grow
Defines the ability for a flex item to grow if needed.
(unitless values serve as proportion) An item set at 2
would be twice as big as an item set at 1.
.item {
flex-grow: <number>; /* default = 0 */
}
flex-shrink
Defines the ability for a flex item to shrink if needed.
.item {
flex-shrink: <number>; /* default = 0 */
}
Core Concepts
flex-basis
Defines the default size of an element - before remaining
space is distributed. Length or keyword values.
.item {
flex-basis: <number>;
}
If set to 0, the extra space around it is not factored in.
If set to auto (keyword), the extra space is distributed by
its flex-grow value
Core Concepts
flex (shortcut)
Combines flex-grow, flex-shrink (opt) and flex-basis (opt).
Default = 0 1 auto
RECOMMENDED over individual properties.
.item {
flex: 1 0 0;
}
1
Let’s look at some Code
To the text-editor!
Some other examples (that I didn’t have time to build)
▪ https://dl.dropboxusercontent.com/u/444684/flexbox/flexbox1.html
▪ https://dl.dropboxusercontent.com/u/444684/flexbox/flexbox2.html
▪ https://dl.dropboxusercontent.com/u/444684/flexbox/flexbox3.html
Browser Adoption
Can I Use? - caniuse.com
Flexbox is the current new and now way of
thinking about CSS layout - but not the end.
Historic and current layout practices
▪ Table based layouts
▪ Float based layouts (CSS1)
▪ Positioning (CSS2)
▪ Flexbox “This is real layout. It’s not a hack” - Jeremy Keith
▫ Flexbox (old)
▫ Flexbox (mid/transitional)
▫ Flexbox (standard/final)
The future is coming ‘soon’ and will likely build upon the
flexbox model and techniques.
▪ Grid Layout (ie10 has adopted an early specification)
▪ Regions and Exclusions (Adobe initiative)
● https://developer.mozilla.org/en-
US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes
● http://www.sitepoint.com/are-we-ready-to-use-flexbox/
● https://css-tricks.com/using-flexbox/
● http://caniuse.com/#feat=flexbox
● https://css-tricks.com/snippets/css/a-guide-to-flexbox/
● https://www.smashingmagazine.com/2013/05/centering-elements-with-flexbox/
● https://www.smashingmagazine.com/2015/08/flexible-future-for-web-design-with-flexbox/
References

More Related Content

What's hot (20)

PPTX
Css backgrounds
AbhishekMondal42
 
PPT
Css Ppt
Hema Prasanth
 
PPTX
Media queries A to Z
Shameem Reza
 
PPTX
Introduction to flexbox
Jyoti Gautam
 
PPTX
Flex box
Harish Karthick
 
PPTX
Html5 tutorial for beginners
Singsys Pte Ltd
 
PPTX
Introducing Cascading Style Sheets
St. Petersburg College
 
ODP
HTML5
Hatem Mahmoud
 
PPSX
Introduction to Html5
www.netgains.org
 
PDF
CSS Day: CSS Grid Layout
Rachel Andrew
 
PDF
Intro to HTML and CSS basics
Eliran Eliassy
 
PPTX
Beginners css tutorial for web designers
Singsys Pte Ltd
 
PPTX
Complete Lecture on Css presentation
Salman Memon
 
PPTX
SASS - CSS with Superpower
Kanchha kaji Prajapati
 
PPTX
HTML/HTML5
People Strategists
 
PPTX
Java script
Abhishek Kesharwani
 
PPT
Span and Div tags in HTML
Biswadip Goswami
 
PPT
CSS Basics
WordPress Memphis
 
PDF
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Stephen Hay
 
PPT
Introduction to Javascript
Amit Tyagi
 
Css backgrounds
AbhishekMondal42
 
Css Ppt
Hema Prasanth
 
Media queries A to Z
Shameem Reza
 
Introduction to flexbox
Jyoti Gautam
 
Flex box
Harish Karthick
 
Html5 tutorial for beginners
Singsys Pte Ltd
 
Introducing Cascading Style Sheets
St. Petersburg College
 
Introduction to Html5
www.netgains.org
 
CSS Day: CSS Grid Layout
Rachel Andrew
 
Intro to HTML and CSS basics
Eliran Eliassy
 
Beginners css tutorial for web designers
Singsys Pte Ltd
 
Complete Lecture on Css presentation
Salman Memon
 
SASS - CSS with Superpower
Kanchha kaji Prajapati
 
HTML/HTML5
People Strategists
 
Java script
Abhishek Kesharwani
 
Span and Div tags in HTML
Biswadip Goswami
 
CSS Basics
WordPress Memphis
 
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Stephen Hay
 
Introduction to Javascript
Amit Tyagi
 

Similar to CSS Flexbox (flexible box layout) (20)

PDF
Show & tell - Flex in flux
Dan Dineen
 
PDF
Putting Flexbox into Practice
Zoe Gillenwater
 
PDF
Leveling Up with Flexbox (Smashing Conference)
Zoe Gillenwater
 
PDF
Putting Flexbox into Practice (Fronteers)
Zoe Gillenwater
 
PDF
Is Flexbox the Future of Layout?
jameswillweb
 
PDF
Is Flexbox the Future of Layout -bdconf
jameswillweb
 
PPTX
CSS3 Flex Layout
Neha Sharma
 
PDF
Flexbox Will Shock You!
Scott Vandehey
 
PPTX
flexbox report
LearningTech
 
PDF
Leveling Up With Flexbox (Smart Web Conference)
Zoe Gillenwater
 
PDF
A complete guide to flexbox
Bytes Technolab Inc.
 
PDF
Intro to Flexbox with Real Word Examples
Jennifer Bland
 
PPTX
Understanding the flex layout
Barak Drechsler
 
PPTX
Intro to Flexbox - A Magical CSS Property
Adam Soucie
 
PDF
Flexbox: One Giant Leap for Web Layout (Breaking Development 2013)
Stephen Hay
 
PDF
Flexbox Cheatsheet novadesignswebdevwlopment.pdf
sukumartripathy600
 
PDF
Flexboxsheet
mustafa sarac
 
PPTX
digital swifton
digitalswifton
 
PDF
Introduction to css flexbox
Markandan R
 
PDF
Flex Web Development.pdf
SEO expate Bangladesh Ltd
 
Show & tell - Flex in flux
Dan Dineen
 
Putting Flexbox into Practice
Zoe Gillenwater
 
Leveling Up with Flexbox (Smashing Conference)
Zoe Gillenwater
 
Putting Flexbox into Practice (Fronteers)
Zoe Gillenwater
 
Is Flexbox the Future of Layout?
jameswillweb
 
Is Flexbox the Future of Layout -bdconf
jameswillweb
 
CSS3 Flex Layout
Neha Sharma
 
Flexbox Will Shock You!
Scott Vandehey
 
flexbox report
LearningTech
 
Leveling Up With Flexbox (Smart Web Conference)
Zoe Gillenwater
 
A complete guide to flexbox
Bytes Technolab Inc.
 
Intro to Flexbox with Real Word Examples
Jennifer Bland
 
Understanding the flex layout
Barak Drechsler
 
Intro to Flexbox - A Magical CSS Property
Adam Soucie
 
Flexbox: One Giant Leap for Web Layout (Breaking Development 2013)
Stephen Hay
 
Flexbox Cheatsheet novadesignswebdevwlopment.pdf
sukumartripathy600
 
Flexboxsheet
mustafa sarac
 
digital swifton
digitalswifton
 
Introduction to css flexbox
Markandan R
 
Flex Web Development.pdf
SEO expate Bangladesh Ltd
 
Ad

Recently uploaded (20)

PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Ad

CSS Flexbox (flexible box layout)

  • 2. The CSS3 Flexible Box, or flexbox, is a layout mode providing for the arrangement of elements on a page such that the elements behave predictably when the page layout must accommodate different screen sizes and different display devices. Mozilla Developer Network
  • 3. What is Flexbox? Designed to provide a better way to lay out, align, and distribute space among items in a container - even when dynamic. Flexbox is a CSS layout mode designed to ensure that elements behave predictably in different screen sizes and devices. … it creates Intelligent boxes. Easily Defined in CSS and markup (incl. media queries). Directionally agnostic. (block = vertically-based & inline = horizontally-based) Best used for smaller modules over broader layout
  • 4. “Old” and “New” syntax Oddly, the syntax has changed since initial conception - which has resulted in common references to “old” and “new” versions. Weaving together the two, (and in-betweens) provides decent browser support - especially for order-controlled grids ▪ Chris Coyier (2013) Requires additional code and prefixed code when authoring for best results. … consider a js library (autoprefixer) Examples NEW: display: flex; TWEEN: display; -ms-flexbox; OLD: display: box;
  • 5. Core Concepts Flexbox consists of: ▪Flex Containers ▪Flex Items Flex Container Declared on an element using the display property display: flex or display: inline-flex Flex Item Flex items are positioned inside of a flex container along a “flex line”. By default 1 flex line per flex container. contaner < items
  • 6. Core Concepts Flex Line (axis, rope) Flex items are laid out in a single “line” (default) or on several “lines” according to the flex-wrap property. No longer think about top-to-bottom or left-to-right. Abandon rows/columns thinking. direction orientation
  • 7. Core Concepts Flex Line In addition to Alignment, Orientation and Direction, flex lines can be reordered! This is huge. We can now structure our HTML for semantics, accessibility, and SEO .item { order: <integer>; } order By default, flex items are laid out in source order
  • 8. Core Concepts Nested Flex Lines Each flexbox layout (box) can contain another set that is on their own line. Nested flexboxes
  • 9. Core Concepts flex-wrap By default all flex items will try to fit together into one line. This can be changed and direction can be modified using the flex-wrap property. .container { flex-wrap: wrap; nowrap | wrap | wrap reverse }
  • 10. Core Concepts flex-grow Defines the ability for a flex item to grow if needed. (unitless values serve as proportion) An item set at 2 would be twice as big as an item set at 1. .item { flex-grow: <number>; /* default = 0 */ } flex-shrink Defines the ability for a flex item to shrink if needed. .item { flex-shrink: <number>; /* default = 0 */ }
  • 11. Core Concepts flex-basis Defines the default size of an element - before remaining space is distributed. Length or keyword values. .item { flex-basis: <number>; } If set to 0, the extra space around it is not factored in. If set to auto (keyword), the extra space is distributed by its flex-grow value
  • 12. Core Concepts flex (shortcut) Combines flex-grow, flex-shrink (opt) and flex-basis (opt). Default = 0 1 auto RECOMMENDED over individual properties. .item { flex: 1 0 0; }
  • 13. 1 Let’s look at some Code To the text-editor!
  • 14. Some other examples (that I didn’t have time to build) ▪ https://dl.dropboxusercontent.com/u/444684/flexbox/flexbox1.html ▪ https://dl.dropboxusercontent.com/u/444684/flexbox/flexbox2.html ▪ https://dl.dropboxusercontent.com/u/444684/flexbox/flexbox3.html
  • 15. Browser Adoption Can I Use? - caniuse.com
  • 16. Flexbox is the current new and now way of thinking about CSS layout - but not the end. Historic and current layout practices ▪ Table based layouts ▪ Float based layouts (CSS1) ▪ Positioning (CSS2) ▪ Flexbox “This is real layout. It’s not a hack” - Jeremy Keith ▫ Flexbox (old) ▫ Flexbox (mid/transitional) ▫ Flexbox (standard/final) The future is coming ‘soon’ and will likely build upon the flexbox model and techniques. ▪ Grid Layout (ie10 has adopted an early specification) ▪ Regions and Exclusions (Adobe initiative)
  • 17. ● https://developer.mozilla.org/en- US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes ● http://www.sitepoint.com/are-we-ready-to-use-flexbox/ ● https://css-tricks.com/using-flexbox/ ● http://caniuse.com/#feat=flexbox ● https://css-tricks.com/snippets/css/a-guide-to-flexbox/ ● https://www.smashingmagazine.com/2013/05/centering-elements-with-flexbox/ ● https://www.smashingmagazine.com/2015/08/flexible-future-for-web-design-with-flexbox/ References