SlideShare a Scribd company logo
Flexbox Every Developers Dream
• Welcome to the first of Kika’s series on CSS’s newest
framework Flexbox! In this series we will look into
how to use Flexbox to build and manage your
website!
• There was a time in the not so distant future, that
tables ruled the field of HTML page development.
Developers did not bother getting bogged down in
<div> or Dreamweaver layers, as tables made up the
foundation of their website templates. Over time,
however, with advancements in multimedia and
mobile device capabilities, which required cleaner
coding, the standard shifted toward table-less html
<div>. This became the new standard for website
development.
• However, even with the simplification of coding
under the new framework, early CSS came with
challenges of its own. Simple vertical alignment
of a child div inside a parent div required writing
extra research, coding and testing. This was just
one of the many complications with early CSS
that web developers had to deal with.
• Since then, new HTML and CSS frameworks
have been developed like Bootstrap and Skeleton
that were much more developer friendly. One of
these frameworks is CSS3’s newest layout;
Flexbox.
According to W3Schools.com:
• “Use of flexbox [or Flexible Boxes] ensures that
elements behave predictably when the page
layout must accommodate different screen sizes
and different display devices.
• For many applications, the flexible box model
provides an improvement over the block model
in that it does not use floats, nor do the flex
container’s margins collapse with the margins of
its contents.”
• In order to give you a better idea of how Flexbox
can work for you, let’s take a closer look at it’s
functionality!
#1 Adjusting multiple child elements
with equal width inside a parent div
• Supposed you want to have a form with two fields
vertically aligned with one another other vertically, each
having an equal width. In the past, a common solution to
this problem was to implement
the float:left and float:right declarations.
• Now under Flexbox, you can simply add the display:
flex declaration to the parent container (example-1-
parent) and add flex:1 declaration to the child div.
• In this screenshot, display:flex would cause your
parent container to aligned its children divs
vertically, while flex:1 cause the children divs to
have evenly distributed width.
#2 Setting multiple columns with
varying width, margins and ordering.
• Adding display:flex to your Container css code will
cause the Divs to sit side by side and by default
allocates more page space to the column with the
most text by default.
• This can be good as it adds more space for areas
with more content, but suppose you want all your
columns to be the same width?
• In this case, like with the previous example, you
would add the flex: 1 declaration to each child div.
This will bring each column to an equal width. The
reason for this is that the flex: 1 declaration
represents a kind of baseline value.
• In the case that you wanted to assign a given column
more space on the page, in relation to your other
columns, you would simply have to assign a higher
flex value to that column.
• For example, if you had 3 columns (A,B,C), and you
wanted column A to be 2x bigger than the other two,
then you would assign column a with the flex: 2
syntax. Similarly, if you wanted column A to be 3x
bigger than the other two you would assign flex: 3
syntax. As flex: 1 is the base value that makes all
elements equally distributed, then any value you
place on other divs in the same container will act as
a multiplier of the baseline.
• Ex:
• .column-layout {
• max-width: 1300px;
• background-colour: #fff;
• margin: 40px auto 0 auto;
• line-height: 1.65;
• padding: 20px 50px;
• display: flex;
• }
• .column-A {
• flex: 2;
• }
• .column-B {
• flex: 1;
• }
• .column-A {
• flex: 1;
• }
Ordering
• Ordering your content is a breeze with Flexbox,
using the the previous example with our 3
columns. If you would like to reorder your
columns from the A,B,C order to B,C,A . you
must simply add the order declaration below the
flex.
• Ex:
• .column-layout {
• max-width: 1300px;
• background-colour: #fff;
• margin: 40px auto 0 auto;
• line-height: 1.65;
• padding: 20px 50px;
• display: flex;
• }
• .column-A {
• flex: 1;
• order: 3;
• }
• .column-B {
• flex: 1;
• order: 1;
• }
• .column-A {
• flex: 1;
• order: 2
• }
Margins
• So we have looked at how to set up and order
multiple content columns and reorder and
reshape them using Flexbox.
• Now let’s take a look at how we can further
customize these columns by including margins
between the columns we have set up:
• In the past, the best way of changing the margins
in your layout was to adjust the div’s width.
However with Flexbox, adding margins is as easy
as adding display:flex and justify-content:space-
between to the parent container and add the
syntaxes box-sizing:border-box (as you would in
the past) but instead of modifying the width of
the child container you would input the
following declaration: flex-basis: x%;
• Ex:
• .parent-container {
• max-width: 140px;
• margin: 40px auto 0 auto;
• display: flex;
• justify-content: space-between;
• }
• .child {
• padding: 20px;
• box-sizing: border-box;
• margin-bottom: 20px;
• flex-basis: 30%;
• }
• This concludes our initial look into Flexbox
framework, we hoped you enjoyed this first
chapter and that is proved useful in the
development of your website. Stay tuned for the
next chapter of our series on Flexbox, where we
will be covering container responsiveness.
• Created by:
Kika Marketing and Communications

More Related Content

Similar to Flexbox every developers dream

The New CSS Layout - Dutch PHP Conference
The New CSS Layout - Dutch PHP ConferenceThe New CSS Layout - Dutch PHP Conference
The New CSS Layout - Dutch PHP Conference
Rachel Andrew
 
Enhancing Responsiveness with Flexbox (RWD Summit)
Enhancing Responsiveness with Flexbox (RWD Summit)Enhancing Responsiveness with Flexbox (RWD Summit)
Enhancing Responsiveness with Flexbox (RWD Summit)
Zoe Gillenwater
 
Flexbox Will Shock You!
Flexbox Will Shock You!Flexbox Will Shock You!
Flexbox Will Shock You!
Scott Vandehey
 
Intro to Flexbox with Real Word Examples
Intro to Flexbox with Real Word ExamplesIntro to Flexbox with Real Word Examples
Intro to Flexbox with Real Word Examples
Jennifer Bland
 
The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS Layout
Zoe Gillenwater
 
Is Flexbox the Future of Layout?
Is Flexbox the Future of Layout?Is Flexbox the Future of Layout?
Is Flexbox the Future of Layout?
jameswillweb
 
A complete guide to flexbox
A complete guide to flexboxA complete guide to flexbox
A complete guide to flexbox
Bytes Technolab Inc.
 
[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
Kobkrit Viriyayudhakorn
 
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Stephen Hay
 
Putting Flexbox into Practice
Putting Flexbox into PracticePutting Flexbox into Practice
Putting Flexbox into Practice
Zoe Gillenwater
 
But what about old browsers?
But what about old browsers?But what about old browsers?
But what about old browsers?
Rachel Andrew
 
Building Layouts with CSS
Building Layouts with CSSBuilding Layouts with CSS
Building Layouts with CSS
Boris Paillard
 
Basics of expression blend4
Basics of expression blend4Basics of expression blend4
Basics of expression blend4
Samson Tennela
 
Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)
Zoe Gillenwater
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)
Rajat Pratap Singh
 
Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)
Zoe Gillenwater
 
Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)
Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)
Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)
Zoe Gillenwater
 
MTA css layouts
MTA css layoutsMTA css layouts
MTA css layouts
Dhairya Joshi
 
flexbox report
flexbox reportflexbox report
flexbox report
LearningTech
 
Web technologies-course 04.pptx
Web technologies-course 04.pptxWeb technologies-course 04.pptx
Web technologies-course 04.pptx
Stefan Oprea
 

Similar to Flexbox every developers dream (20)

The New CSS Layout - Dutch PHP Conference
The New CSS Layout - Dutch PHP ConferenceThe New CSS Layout - Dutch PHP Conference
The New CSS Layout - Dutch PHP Conference
 
Enhancing Responsiveness with Flexbox (RWD Summit)
Enhancing Responsiveness with Flexbox (RWD Summit)Enhancing Responsiveness with Flexbox (RWD Summit)
Enhancing Responsiveness with Flexbox (RWD Summit)
 
Flexbox Will Shock You!
Flexbox Will Shock You!Flexbox Will Shock You!
Flexbox Will Shock You!
 
Intro to Flexbox with Real Word Examples
Intro to Flexbox with Real Word ExamplesIntro to Flexbox with Real Word Examples
Intro to Flexbox with Real Word Examples
 
The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS Layout
 
Is Flexbox the Future of Layout?
Is Flexbox the Future of Layout?Is Flexbox the Future of Layout?
Is Flexbox the Future of Layout?
 
A complete guide to flexbox
A complete guide to flexboxA complete guide to flexbox
A complete guide to 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
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
 
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
Flexbox: One Giant Leap for Web Layout (GenerateConf 2013)
 
Putting Flexbox into Practice
Putting Flexbox into PracticePutting Flexbox into Practice
Putting Flexbox into Practice
 
But what about old browsers?
But what about old browsers?But what about old browsers?
But what about old browsers?
 
Building Layouts with CSS
Building Layouts with CSSBuilding Layouts with CSS
Building Layouts with CSS
 
Basics of expression blend4
Basics of expression blend4Basics of expression blend4
Basics of expression blend4
 
Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)
 
Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)
 
Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)
Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)
Enhancing Responsiveness with Flexbox (CSS Conf EU 2015)
 
MTA css layouts
MTA css layoutsMTA css layouts
MTA css layouts
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Web technologies-course 04.pptx
Web technologies-course 04.pptxWeb technologies-course 04.pptx
Web technologies-course 04.pptx
 

Recently uploaded

2022 Vintage Roman Numerals Men Rings
2022 Vintage Roman  Numerals  Men  Rings2022 Vintage Roman  Numerals  Men  Rings
2022 Vintage Roman Numerals Men Rings
aragme
 
Cover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SUCover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SU
msthrill
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results
 
Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...
Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...
Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
valvereliz227
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
 
Best Competitive Marble Pricing in Dubai - ☎ 9928909666
Best Competitive Marble Pricing in Dubai - ☎ 9928909666Best Competitive Marble Pricing in Dubai - ☎ 9928909666
Best Competitive Marble Pricing in Dubai - ☎ 9928909666
Stone Art Hub
 
AI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your BusinessAI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your Business
Arijit Dutta
 
GKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt PresentationGKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt Presentation
GraceKohler1
 
Kirill Klip GEM Royalty TNR Gold Lithium Presentation
Kirill Klip GEM Royalty TNR Gold Lithium PresentationKirill Klip GEM Royalty TNR Gold Lithium Presentation
Kirill Klip GEM Royalty TNR Gold Lithium Presentation
Kirill Klip
 
The Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb PlatformThe Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb Platform
SabaaSudozai
 
PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...
PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...
PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...
Ksquare Energy Pvt. Ltd.
 
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
concepsionchomo153
 
Science Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around UsScience Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around Us
PennapaKeavsiri
 
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper PresentationKirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip
 
list of states and organizations .pdf
list of  states  and  organizations .pdflist of  states  and  organizations .pdf
list of states and organizations .pdf
Rbc Rbcua
 
Ellen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women Magazine
Ellen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women MagazineEllen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women Magazine
Ellen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women Magazine
CIOWomenMagazine
 
IMG_20240615_091110.pdf dpboss guessing
IMG_20240615_091110.pdf dpboss  guessingIMG_20240615_091110.pdf dpboss  guessing
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
my Pandit
 
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your TasteZodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
my Pandit
 

Recently uploaded (20)

2022 Vintage Roman Numerals Men Rings
2022 Vintage Roman  Numerals  Men  Rings2022 Vintage Roman  Numerals  Men  Rings
2022 Vintage Roman Numerals Men Rings
 
Cover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SUCover Story - China's Investment Leader - Dr. Alyce SU
Cover Story - China's Investment Leader - Dr. Alyce SU
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
 
Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...
Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...
Dpboss Matka Guessing Satta Matta Matka Kalyan panel Chart Indian Matka Dpbos...
 
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
欧洲杯赌球-欧洲杯赌球买球官方官网-欧洲杯赌球比赛投注官网|【​网址​🎉ac55.net🎉​】
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
 
Best Competitive Marble Pricing in Dubai - ☎ 9928909666
Best Competitive Marble Pricing in Dubai - ☎ 9928909666Best Competitive Marble Pricing in Dubai - ☎ 9928909666
Best Competitive Marble Pricing in Dubai - ☎ 9928909666
 
AI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your BusinessAI Transformation Playbook: Thinking AI-First for Your Business
AI Transformation Playbook: Thinking AI-First for Your Business
 
GKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt PresentationGKohler - Retail Scavenger Hunt Presentation
GKohler - Retail Scavenger Hunt Presentation
 
Kirill Klip GEM Royalty TNR Gold Lithium Presentation
Kirill Klip GEM Royalty TNR Gold Lithium PresentationKirill Klip GEM Royalty TNR Gold Lithium Presentation
Kirill Klip GEM Royalty TNR Gold Lithium Presentation
 
The Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb PlatformThe Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb Platform
 
PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...
PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...
PM Surya Ghar Muft Bijli Yojana: Online Application, Eligibility, Subsidies &...
 
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
 
Science Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around UsScience Around Us Module 2 Matter Around Us
Science Around Us Module 2 Matter Around Us
 
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper PresentationKirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper Presentation
 
list of states and organizations .pdf
list of  states  and  organizations .pdflist of  states  and  organizations .pdf
list of states and organizations .pdf
 
Ellen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women Magazine
Ellen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women MagazineEllen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women Magazine
Ellen Burstyn: From Detroit Dreamer to Hollywood Legend | CIO Women Magazine
 
IMG_20240615_091110.pdf dpboss guessing
IMG_20240615_091110.pdf dpboss  guessingIMG_20240615_091110.pdf dpboss  guessing
IMG_20240615_091110.pdf dpboss guessing
 
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
Unveiling the Dynamic Personalities, Key Dates, and Horoscope Insights: Gemin...
 
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your TasteZodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
Zodiac Signs and Food Preferences_ What Your Sign Says About Your Taste
 

Flexbox every developers dream

  • 2. • Welcome to the first of Kika’s series on CSS’s newest framework Flexbox! In this series we will look into how to use Flexbox to build and manage your website! • There was a time in the not so distant future, that tables ruled the field of HTML page development. Developers did not bother getting bogged down in <div> or Dreamweaver layers, as tables made up the foundation of their website templates. Over time, however, with advancements in multimedia and mobile device capabilities, which required cleaner coding, the standard shifted toward table-less html <div>. This became the new standard for website development.
  • 3.
  • 4. • However, even with the simplification of coding under the new framework, early CSS came with challenges of its own. Simple vertical alignment of a child div inside a parent div required writing extra research, coding and testing. This was just one of the many complications with early CSS that web developers had to deal with. • Since then, new HTML and CSS frameworks have been developed like Bootstrap and Skeleton that were much more developer friendly. One of these frameworks is CSS3’s newest layout; Flexbox.
  • 5. According to W3Schools.com: • “Use of flexbox [or Flexible Boxes] ensures that elements behave predictably when the page layout must accommodate different screen sizes and different display devices. • For many applications, the flexible box model provides an improvement over the block model in that it does not use floats, nor do the flex container’s margins collapse with the margins of its contents.”
  • 6. • In order to give you a better idea of how Flexbox can work for you, let’s take a closer look at it’s functionality!
  • 7. #1 Adjusting multiple child elements with equal width inside a parent div • Supposed you want to have a form with two fields vertically aligned with one another other vertically, each having an equal width. In the past, a common solution to this problem was to implement the float:left and float:right declarations.
  • 8. • Now under Flexbox, you can simply add the display: flex declaration to the parent container (example-1- parent) and add flex:1 declaration to the child div. • In this screenshot, display:flex would cause your parent container to aligned its children divs vertically, while flex:1 cause the children divs to have evenly distributed width.
  • 9. #2 Setting multiple columns with varying width, margins and ordering. • Adding display:flex to your Container css code will cause the Divs to sit side by side and by default allocates more page space to the column with the most text by default. • This can be good as it adds more space for areas with more content, but suppose you want all your columns to be the same width? • In this case, like with the previous example, you would add the flex: 1 declaration to each child div. This will bring each column to an equal width. The reason for this is that the flex: 1 declaration represents a kind of baseline value.
  • 10. • In the case that you wanted to assign a given column more space on the page, in relation to your other columns, you would simply have to assign a higher flex value to that column. • For example, if you had 3 columns (A,B,C), and you wanted column A to be 2x bigger than the other two, then you would assign column a with the flex: 2 syntax. Similarly, if you wanted column A to be 3x bigger than the other two you would assign flex: 3 syntax. As flex: 1 is the base value that makes all elements equally distributed, then any value you place on other divs in the same container will act as a multiplier of the baseline.
  • 11. • Ex: • .column-layout { • max-width: 1300px; • background-colour: #fff; • margin: 40px auto 0 auto; • line-height: 1.65; • padding: 20px 50px; • display: flex; • } • .column-A { • flex: 2; • } • .column-B { • flex: 1; • } • .column-A { • flex: 1; • }
  • 12. Ordering • Ordering your content is a breeze with Flexbox, using the the previous example with our 3 columns. If you would like to reorder your columns from the A,B,C order to B,C,A . you must simply add the order declaration below the flex.
  • 13. • Ex: • .column-layout { • max-width: 1300px; • background-colour: #fff; • margin: 40px auto 0 auto; • line-height: 1.65; • padding: 20px 50px; • display: flex; • } • .column-A { • flex: 1; • order: 3; • } • .column-B { • flex: 1; • order: 1; • } • .column-A { • flex: 1; • order: 2 • }
  • 14. Margins • So we have looked at how to set up and order multiple content columns and reorder and reshape them using Flexbox. • Now let’s take a look at how we can further customize these columns by including margins between the columns we have set up:
  • 15. • In the past, the best way of changing the margins in your layout was to adjust the div’s width. However with Flexbox, adding margins is as easy as adding display:flex and justify-content:space- between to the parent container and add the syntaxes box-sizing:border-box (as you would in the past) but instead of modifying the width of the child container you would input the following declaration: flex-basis: x%;
  • 16. • Ex: • .parent-container { • max-width: 140px; • margin: 40px auto 0 auto; • display: flex; • justify-content: space-between; • } • .child { • padding: 20px; • box-sizing: border-box; • margin-bottom: 20px; • flex-basis: 30%; • }
  • 17. • This concludes our initial look into Flexbox framework, we hoped you enjoyed this first chapter and that is proved useful in the development of your website. Stay tuned for the next chapter of our series on Flexbox, where we will be covering container responsiveness.
  • 18. • Created by: Kika Marketing and Communications