SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
A Complete Guide To Flexbox
What is Flexbox?
This is a way of designing, aligning items and distributing surplus space.
Flex stands for flexibility, adaptability. Thus, flexible layout elements are flexible boxes. The
ability to fill extra areas without using javascript is one of the key advantages of flexbox.
Flexbox is a one-dimensional layout approach that allows you to arrange things in rows or
columns.
CSS flexbox is superior for horizontal and vertical alignment of objects within the section,
even if their size is unknown and/or dynamic.
Flexbox = Flexible + Box
Flex Browser & Layout Support:
By September 2020, CSS Flexible Box Layouts are supported by 98.69% of the installed
browsers, or by 99.29% of the desktop and 100% of mobile.
All desktop/mobile/tablet browsers with the newest version support, in addition to the IE 11
desktop browser. Partial support is provided in the IE 11 desktop browser.
Flex CSS Syntax:
div { display: flex; } => [ div: Selector | display: Property | flex: Value ]
Flexbox Example With Different Requirement:
Main axis
Main axis stands for a flex container as the primary axis, all flex items are managed with the
main axis.
Main-start | main-end
The flex items are placed within the container starting on the main-start side and going
toward the main-end side.
Horizontal alignment
Main size | main size property
The width or height of a flex container or flex item, whichever is in the main dimension, is
that box’s main size.
Cross axis
The axis perpendicular to the main axis is called the cross axis. It extends in the cross
dimension.
Cross-start | cross-end
Flex lines are filled with items and placed into the container starting on the cross-start side
of the flex container and going toward the cross-end side.
Vertical alignment
Cross size
Cross size defines all flex items vertical heights.
Also Read:[What Is A Headless Content Management System(CMS)?]
3.1. How to create Flex Containers using flex or
inline-flex
Property: display
Value: flex | inline-flex
Applies to: flex containers
flex: The flex value contains full width.
inline-flex: With the inline-flex value contain inline width based on content.
3.2. How to set Ordering and Orientation in flex.
2.1. Flex Flow Direction: the flex-direction property
Property: flex-direction
Value: row | row-reverse | column | column-reverse
Initial: row
Applies to: flex containers
row: flex items arranged in horizontal alignment, sequence 1 2 3.
row-reverse: flex items arranged in reverse horizontal alignment, sequence 3 2 1.
column: flex items arranged in vertical alignment, sequence 1 2 3.
column-reverse: flex items arranged in reverse vertical alignment, sequence 3 2 1.
3.3. How to wrap content using flex-wrap
Name: flex-wrap
Value: nowrap | wrap | wrap-reverse
Initial: nowrap
Applies to: flex containers
nowrap: The flex container is single-line.
wrap: The flex container is multi-line.
wrap-reverse: Same as wrap but, line sequence reverse order not items.
3.4. How to display contents using Display Order
Property
Name: order
Value: <integer>
Initial: 0
Applies to: flex items
order: defines the flex items order.
3.5. How to set width using Flex items width
Applies to: flex items
.flex-item { width: 80px; } => Set flex items width with 80px.
.flex-item { width: 80px; flex: auto; } => Set flex items width according to row remaining
space but, consider flex items width 80px or more.
3.6. How to set content horizontally using justify-content
property.
flex items horizontal alignment property:
Name: justify-content
Value: flex-start | flex-end | center | space-between | space-around
Initial: flex-start
Applies to: flex containers
3.7. How to set content vertically using the align
property?
flex containers vertical alignment property:
Name: align-items
Value: flex-start | flex-end | center | baseline | stretch
Initial: stretch
Applies to: flex containers
Name: align-self
Value: auto | flex-start | flex-end | center | baseline | stretch
Initial: auto
Applies to: flex items
baseline: practically baseline alignment consider same as flex-start.
Flex Property Index:
Not Supported CSS Property in Flexbox:
In the context of Flexbox Layout, some characteristics designed to assume the block layout
don’t apply.
CSS Property not supported:
The column* properties in the Specific[CSS3 col-*] The Multi-column Layout module has no
impact on a flex container.
Float and clear have no effect and do not take off-flow on the flex item. The float property
may, however, still affect the flex box.
A flex item has no vertical-align effect.
the ::first-line and ::first-letter pseudo-elements do not apply to flex containers, and flex
containers do not contribute a first formatted line or first letter to their ancestors.
Wrapping up
Over the next few years there will still be handy floats, tables and all other strategies for
layouting dead soon. Each member of this “family of layout tools” nonetheless has some
limitations in developing layouts. These drawbacks stem from standards which did not
anticipate the layouts of today. That is why Flexbox comes in handy.

Weitere ähnliche Inhalte

Ähnlich wie A complete guide to flexbox

CSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive DesignCSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive Design
Arash Milani
 

Ähnlich wie A complete guide to flexbox (20)

CSS3 Flex Layout
CSS3 Flex LayoutCSS3 Flex Layout
CSS3 Flex Layout
 
Flexbox Will Shock You!
Flexbox Will Shock You!Flexbox Will Shock You!
Flexbox Will Shock You!
 
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
 
Enhancing Responsiveness With Flexbox (CSS Day)
Enhancing Responsiveness With Flexbox (CSS Day)Enhancing Responsiveness With Flexbox (CSS Day)
Enhancing Responsiveness With Flexbox (CSS Day)
 
Flex box
Flex boxFlex box
Flex box
 
Is Flexbox the Future of Layout?
Is Flexbox the Future of Layout?Is Flexbox the Future of Layout?
Is Flexbox the Future of Layout?
 
Leveling Up With Flexbox (Smart Web Conference)
Leveling Up With Flexbox (Smart Web Conference)Leveling Up With Flexbox (Smart Web Conference)
Leveling Up With Flexbox (Smart Web Conference)
 
Lecture-9.pptx
Lecture-9.pptxLecture-9.pptx
Lecture-9.pptx
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Using Flexbox Today (CSS Summit 2016)
Using Flexbox Today (CSS Summit 2016)Using Flexbox Today (CSS Summit 2016)
Using Flexbox Today (CSS Summit 2016)
 
#4 HTML & CSS [know-how]
#4 HTML & CSS [know-how]#4 HTML & CSS [know-how]
#4 HTML & CSS [know-how]
 
Understanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdfUnderstanding Flexbox Layout in React Native.pdf
Understanding Flexbox Layout in React Native.pdf
 
Layout with flexbox
Layout with flexboxLayout with flexbox
Layout with flexbox
 
Building Layouts with CSS
Building Layouts with CSSBuilding Layouts with CSS
Building Layouts with CSS
 
Enhancing Responsiveness With Flexbox (Smashing Conference)
Enhancing Responsiveness With Flexbox (Smashing Conference)Enhancing Responsiveness With Flexbox (Smashing Conference)
Enhancing Responsiveness With Flexbox (Smashing Conference)
 
CSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive DesignCSS3 Flexbox & Responsive Design
CSS3 Flexbox & Responsive Design
 
CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)CSS Flexbox (flexible box layout)
CSS Flexbox (flexible box layout)
 
The New CSS Layout - dotCSS
The New CSS Layout - dotCSSThe New CSS Layout - dotCSS
The New CSS Layout - dotCSS
 
Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)
 
Using Flexbox Today (Frontend United 2016)
Using Flexbox Today (Frontend United 2016)Using Flexbox Today (Frontend United 2016)
Using Flexbox Today (Frontend United 2016)
 

Mehr von Bytes Technolab Inc.

Mehr von Bytes Technolab Inc. (14)

Step-by-Step Guide to Developing a Successful iOS App.pdf
Step-by-Step Guide to Developing a Successful iOS App.pdfStep-by-Step Guide to Developing a Successful iOS App.pdf
Step-by-Step Guide to Developing a Successful iOS App.pdf
 
Step-by-Step Guide to Developing a Successful iOS App.docx
Step-by-Step Guide to Developing a Successful iOS App.docxStep-by-Step Guide to Developing a Successful iOS App.docx
Step-by-Step Guide to Developing a Successful iOS App.docx
 
Things to Consider While Choosing Mobile App Development Framework.pptx
Things to Consider While Choosing Mobile App Development Framework.pptxThings to Consider While Choosing Mobile App Development Framework.pptx
Things to Consider While Choosing Mobile App Development Framework.pptx
 
Things to Consider While Choosing Mobile App Development Framework.pptx
Things to Consider While Choosing Mobile App Development Framework.pptxThings to Consider While Choosing Mobile App Development Framework.pptx
Things to Consider While Choosing Mobile App Development Framework.pptx
 
Hiring Dedicated MERN Developer Essential Factors to Consider.pdf
Hiring Dedicated MERN Developer Essential Factors to Consider.pdfHiring Dedicated MERN Developer Essential Factors to Consider.pdf
Hiring Dedicated MERN Developer Essential Factors to Consider.pdf
 
Hiring Dedicated MERN Developer Essential Factors to Consider.docx
Hiring Dedicated MERN Developer Essential Factors to Consider.docxHiring Dedicated MERN Developer Essential Factors to Consider.docx
Hiring Dedicated MERN Developer Essential Factors to Consider.docx
 
SWOT Analysis of Native vs Cross-platform for Mobile App Development.pptx
SWOT Analysis of Native vs Cross-platform for Mobile App Development.pptxSWOT Analysis of Native vs Cross-platform for Mobile App Development.pptx
SWOT Analysis of Native vs Cross-platform for Mobile App Development.pptx
 
What makes Flutter the Ideal Choice for Global Startups.pdf
What makes Flutter the Ideal Choice for Global Startups.pdfWhat makes Flutter the Ideal Choice for Global Startups.pdf
What makes Flutter the Ideal Choice for Global Startups.pdf
 
Why Choose Laravel Framework to Develop High-Performing Web Apps in 2023.pptx
Why Choose Laravel Framework to Develop High-Performing Web Apps in 2023.pptxWhy Choose Laravel Framework to Develop High-Performing Web Apps in 2023.pptx
Why Choose Laravel Framework to Develop High-Performing Web Apps in 2023.pptx
 
What makes Flutter the Ideal Choice for Global Startups.docx
What makes Flutter the Ideal Choice for Global Startups.docxWhat makes Flutter the Ideal Choice for Global Startups.docx
What makes Flutter the Ideal Choice for Global Startups.docx
 
What shall you Pre-consider While Integrating Magento 2 with Third-party Apps...
What shall you Pre-consider While Integrating Magento 2 with Third-party Apps...What shall you Pre-consider While Integrating Magento 2 with Third-party Apps...
What shall you Pre-consider While Integrating Magento 2 with Third-party Apps...
 
Top 12 Reasons You Should Invest in Android App Development.pptx
Top 12 Reasons You Should Invest in Android App Development.pptxTop 12 Reasons You Should Invest in Android App Development.pptx
Top 12 Reasons You Should Invest in Android App Development.pptx
 
What shall you Pre-consider While Integrating Magento 2 with Third-partsy App...
What shall you Pre-consider While Integrating Magento 2 with Third-partsy App...What shall you Pre-consider While Integrating Magento 2 with Third-partsy App...
What shall you Pre-consider While Integrating Magento 2 with Third-partsy App...
 
A complete guide to developing a beautiful e commerce mobile application like...
A complete guide to developing a beautiful e commerce mobile application like...A complete guide to developing a beautiful e commerce mobile application like...
A complete guide to developing a beautiful e commerce mobile application like...
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 

A complete guide to flexbox

  • 1. A Complete Guide To Flexbox What is Flexbox? This is a way of designing, aligning items and distributing surplus space. Flex stands for flexibility, adaptability. Thus, flexible layout elements are flexible boxes. The ability to fill extra areas without using javascript is one of the key advantages of flexbox. Flexbox is a one-dimensional layout approach that allows you to arrange things in rows or columns. CSS flexbox is superior for horizontal and vertical alignment of objects within the section, even if their size is unknown and/or dynamic. Flexbox = Flexible + Box
  • 2. Flex Browser & Layout Support: By September 2020, CSS Flexible Box Layouts are supported by 98.69% of the installed browsers, or by 99.29% of the desktop and 100% of mobile. All desktop/mobile/tablet browsers with the newest version support, in addition to the IE 11 desktop browser. Partial support is provided in the IE 11 desktop browser. Flex CSS Syntax: div { display: flex; } => [ div: Selector | display: Property | flex: Value ] Flexbox Example With Different Requirement: Main axis Main axis stands for a flex container as the primary axis, all flex items are managed with the main axis. Main-start | main-end The flex items are placed within the container starting on the main-start side and going toward the main-end side.
  • 3. Horizontal alignment Main size | main size property The width or height of a flex container or flex item, whichever is in the main dimension, is that box’s main size. Cross axis The axis perpendicular to the main axis is called the cross axis. It extends in the cross dimension. Cross-start | cross-end Flex lines are filled with items and placed into the container starting on the cross-start side of the flex container and going toward the cross-end side. Vertical alignment Cross size Cross size defines all flex items vertical heights. Also Read:[What Is A Headless Content Management System(CMS)?] 3.1. How to create Flex Containers using flex or inline-flex Property: display Value: flex | inline-flex Applies to: flex containers flex: The flex value contains full width. inline-flex: With the inline-flex value contain inline width based on content.
  • 4. 3.2. How to set Ordering and Orientation in flex. 2.1. Flex Flow Direction: the flex-direction property Property: flex-direction Value: row | row-reverse | column | column-reverse Initial: row Applies to: flex containers row: flex items arranged in horizontal alignment, sequence 1 2 3. row-reverse: flex items arranged in reverse horizontal alignment, sequence 3 2 1. column: flex items arranged in vertical alignment, sequence 1 2 3. column-reverse: flex items arranged in reverse vertical alignment, sequence 3 2 1. 3.3. How to wrap content using flex-wrap Name: flex-wrap Value: nowrap | wrap | wrap-reverse Initial: nowrap Applies to: flex containers nowrap: The flex container is single-line. wrap: The flex container is multi-line. wrap-reverse: Same as wrap but, line sequence reverse order not items.
  • 5. 3.4. How to display contents using Display Order Property Name: order Value: <integer> Initial: 0 Applies to: flex items order: defines the flex items order.
  • 6. 3.5. How to set width using Flex items width Applies to: flex items .flex-item { width: 80px; } => Set flex items width with 80px. .flex-item { width: 80px; flex: auto; } => Set flex items width according to row remaining space but, consider flex items width 80px or more.
  • 7. 3.6. How to set content horizontally using justify-content property. flex items horizontal alignment property: Name: justify-content Value: flex-start | flex-end | center | space-between | space-around Initial: flex-start Applies to: flex containers
  • 8.
  • 9. 3.7. How to set content vertically using the align property? flex containers vertical alignment property: Name: align-items Value: flex-start | flex-end | center | baseline | stretch Initial: stretch Applies to: flex containers Name: align-self Value: auto | flex-start | flex-end | center | baseline | stretch Initial: auto Applies to: flex items baseline: practically baseline alignment consider same as flex-start.
  • 11. Not Supported CSS Property in Flexbox:
  • 12. In the context of Flexbox Layout, some characteristics designed to assume the block layout don’t apply. CSS Property not supported: The column* properties in the Specific[CSS3 col-*] The Multi-column Layout module has no impact on a flex container. Float and clear have no effect and do not take off-flow on the flex item. The float property may, however, still affect the flex box. A flex item has no vertical-align effect. the ::first-line and ::first-letter pseudo-elements do not apply to flex containers, and flex containers do not contribute a first formatted line or first letter to their ancestors. Wrapping up Over the next few years there will still be handy floats, tables and all other strategies for layouting dead soon. Each member of this “family of layout tools” nonetheless has some limitations in developing layouts. These drawbacks stem from standards which did not anticipate the layouts of today. That is why Flexbox comes in handy.