SlideShare a Scribd company logo
1 of 71
Download to read offline
Building
                   Responsive
                      Layouts
                   by Zoe Mickley Gillenwater
                                    @zomigi
                                  zomigi.com


December 5, 2012
CSS Dev Conf
hello
nice to meet you



                   2
I don’t use a
mobile phone
I have a
process for
eating these

          why
responsive web design works



                              5
         
 what      why
responsive web design means



                              6
                 ?
what      why       how
to do responsive web design



                              7
fluid/liquid layout
uses percentage widths to adapt
      to size of viewport



                                  8
Look at this!
This is so tough!
I'm in such peril
  way up here!




                    9
Oh, wait…




            10
How do
we make
this fluid?




              11
Start with fluid wrapper




                           12
Add opposing floats inside




                             13
3 cols with poor source order




                                14
Nest 2-col layout in 2-col layout




                                    15
Percentages are relative




                           16
Determining nested widths
 width of column
you want to match   ÷      width of
                        parent column   =      width of
                                            nested column




                                                            17
Determining nested widths
 width of column
you want to match   ÷      width of
                        parent column   =      width of
                                            nested column


       target       ÷     context       =    result




                                                            18
Determining nested widths
 width of column
you want to match   ÷      width of
                        parent column   =      width of
                                            nested column


       target       ÷     context       =    result


         20         ÷       80          =      .25
                                            which means
                                              25%

                                                            19
That's more like it




                      20
What about fluid grids?




                          21
Width of this nested block?




                              22
Well that's not right…




                         23
To the laboratory!
 width of column
you want to match   ÷      width of
                        parent column   =      width of
                                            nested column


       target       ÷     context       =    result


         25         ÷      62.5         =       .4
                                            which means
                                              40%

                                                            24
There we go




              25
                   ?
widths             spacing
between and in fluid columns



                               26
Leave a gap via widths




                         27
Declaring fluid margin/padding
• Adjust widths so everything adds to 100%
  • For IE 6/7, make it 99%: avoids problems due
    to rounding % to px
• Nesting affects margin/padding values too
  • Use target÷context formula to match outer
    spacing with inner spacing




                                                   28
Using box-sizing
• Makes px & em margin/padding on fluid
  layout easy
• Standard box model
  • box-sizing: content-box
  • Padding & border added on to width/height
• New box model
  • box-sizing: border-box
  • Padding & border subtracted from width/height


                                                    29
Fluid grid, fixed-width spacing
.column {
  float: left;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0 20px;                  Subtracted
}
                                    from width in
                                    border-box
                                    box model


                                                    30
Use border as faux margin
.column {
  float: left;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0 20px;
  border-left: 10px solid rgba(0,0,0,0);
  -moz-background-clip: padding-box;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

                   Prevents background from
                   displaying under border    31
Negate “margin” at start of row
.column {
  float: left;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0 20px;
  border-left: 10px solid rgba(0,0,0,0);
  -moz-background-clip: padding-box;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}
.row {
  margin-left: -10px;      Removes gap to
}                          left of first column   32
Fix box-sizing in IE 7 and 6
• Feed different dimensions based on
  content-box-model, or
• Use Christian Schaefer's box-sizing polyfill
  https://github.com/Schepp/box-sizing-polyfill
  .column {
    box-sizing: border-box;
    *behavior: url(boxsizing.htc);
  }



                                                  33
I recommend gridpak.com




                          34
                    ?
 fluid              hybrid
one+ column flexible, one+ not



                                 35
Hybrid layout options
• Easy: sidebars first in HTML
  • Float sidebars, main content moves up
    between floats
  • But usually not option in responsive design
• Tricky: main content first in HTML
  • Need to float it, but with what width?
  • One solution: negative margins




                                                  36
Fixed-width
sidebar
starting point




                 37
Add wrapper
with padding
#content-wrapper {
  padding-right: 290px;
}




                          38
Lay out main
content div
#content-main {
  float: left;
  width: 100%;
}




                  39
Float sidebar
#content-secondary {
  float: right;
  width: 250px;
}




                       40
A positive right margin



                   150px




                           41
A negative right margin



                      -150px




                               42
Pull sidebar into gap
#content-secondary {
  float: right;
  width: 250px;
  margin-right: -290px;   Matches
}                         wrapper’s
                          right padding,
                          just negative




                                           43
Success!




           44
To make sidebar show in IE 6
#content-wrapper {
  zoom: 1;             Adds hasLayout
}
#content-main,
#content-secondary {
  display: inline;     Hell if I know,
}                      it just works




                                         45
3-column hybrid layout
• Nest one 2-column layout inside another
• Components of each layout:
  1. Wrapper with padding on one side
  2. Fixed-width sidebar
    •   Same width as padding (or smaller)
    •   Floated same direction as padding
    •   Negative margin matching padding on same side
  3. Fluid column
    •   Floated opposite direction
    •   Width 100%

                                                        46
                 ?
fluid layout    media queries
 feed different styles based on
          viewport size

                                  47
Choosing default styles
•   Start "mobile," layer on wider styles?
•   Start "desktop," layer on narrower styles?
•   Start somewhere in between, layer on both?
•   Learn full pros/cons:
    www.zomigi.com/blog/essential-considerations-
    crafting-quality-media-queries




                                                    48
Starting
in the
middle




           49
Wide-screen media query
/*all the other styles up here*/

@media screen and (min-width: 1200px) {
    /*styles for larger screens in here*/
}




                                            50
Add third column
@media screen and (min-width: 1200px) {
    #nav-main {
        position: fixed;
        top: 136px;
        width: 13%;
        margin: 0;
    }
    #content-main {
        width: 58%;
        margin-left: 18%;
    }
    #content-secondary { width: 20%; }
}
                                          51
Style nav as vertical menu
@media screen and (min-width: 1200px) {
    ...
    #nav-main li {
        float: none;               Stack   links
        margin: 0;
        }
    #nav-main a {
        -moz-border-radius: 0;
        -webkit-border-radius: 0;
        border-radius: 0;        Less tab-like
    }
}

                                                   52
Wide-screen design




                     53
Small-screen media query
/*all the other styles up here*/

@media screen and (max-width: 760px) {
    /*styles for smaller screens in here*/
}




                                             54
Things to fix
too few words per line,
so make all one column




   each too narrow,
 so stack instead and
    put pic on left



                          55
Narrow-
screen
design




          56
Mobile media query
/*all the other styles up here*/

@media screen and (max-width: 550px) {
    /*styles for tiny screens in here*/
}




                                          57
Non-overlapping version
@media screen and (min-width: 551px) and
(max-width: 760px) {
    /*styles for small screens in here*/
}
@media screen and (max-width: 550px) {
    /*styles for tiny screens in here*/
}




                                           58
Changing to single column
@media screen and (max-width: 550px) {
    #content-main, #content-secondary,
    #about, #credits {
        float: none;
        width: 100%;
    }
}




                                         59
Changing feature images
@media screen and (max-width: 550px) {
    ...
    .feature { padding-left: 70px; }
    #feature-candy {
        background-image: url(icon_candy_64.png);
    }
    #feature-pastry {
        background-image: url(icon_pastry_64.png);
    }
    #feature-dessert {
        background-image: url(icon_dessert_64.png);
    }
}
                                                      60
Mobile
design




         61
Viewport meta tag
Forces mobile devices to scale viewport to
actual device width

<meta name="viewport"
   content="width=device-width">




                                             62
Fix iOS zoom problems
<meta name="viewport"
   content="width=device-width, initial-scale=1">
<script src="ios-orientationchange-fix.js">


• Add initial-scale=1 to make page
  reflow when you switch to landscape
• Add script to fix over-zoom bug that crops
  right side of page when you switch
  • See http://filamentgroup.com/lab/a_fix_for_
    the_ios_orientationchange_zoom_bug/

                                                  63
Double-up inside the CSS
Add @viewport rule, upcoming standard,
inside style sheet:
@-moz-viewport{ width:device-width }
@-ms-viewport{ width:device-width }
@-o-viewport{ width:device-width }
@-webkit-viewport{ width:device-width }
@viewport{ width:device-width }




                                         64
conditional
 comments      or   JavaScript
  to deal with IE 8 and earlier


                                  65
Conditional comments
• Split styles into separate sheets and feed
  applicable sheet to IE based on whether
  it's IE on desktop or mobile
• Approach varies based on which set of
  styles are your default




                                               66
Conditional comment when
desktop styles are default
Feed IE Mobile 7 media query sheet:
<link rel="stylesheet" href="global.css" media="all">

<link rel="stylesheet" href="mobile.css" media="all
and (max-width: 700px)">

<!--[if IEMobile 7]>
<link rel="stylesheet" href="mobile.css" media="all">
<![endif]-->



Source: http://blogs.msdn.com/b/iemobile/archive/2010/12/08/targeting-mobile-
optimized-css-at-windows-phone-7.aspx                                         67
Conditional comment when
mobile styles are default
Feed older IE media query sheet, hide from
IE Mobile 7:
<link rel="stylesheet" href="global.css" media="all">

<link rel="stylesheet" href="desktop.css" media="all
and (min-width: 700px)">

<!--[if (lt IE 9)&(!IEMobile 7)]>
<link rel="stylesheet" href="desktop.css" media="all">
<![endif]-->

Source: http://adactio.com/journal/4494/
                                                        68
Pre-fab JavaScript for non-
supporting browsers
• Simply add one of these scripts:
  • Respond: https://github.com/scottjehl/Respond
  • css3-mediaqueries.js:
    http://code.google.com/p/css3-mediaqueries-js/
• Avoid extra HTTP request for non-old-IE
  browsers using conditional comments:
 <!--[if (lt IE 9)&(!IEMobile 7)]>
 <script src="respond.min.js"></script>
 <![endif]-->


                                                 69
View it live
http://stunningcss3.com/code/bakery/




                                       70
Learn more
Download slides and get links at
http://bit.ly/rwdlayout



Zoe Mickley Gillenwater
@zomigi
design@zomigi.com
zomigi.com | stunningcss3.com | flexiblewebbook.com
Photo credits:
“023 Tape measure 006” by Steve James (http://www.flickr.com/photos/steeljam/3350481764/)
“Phone Booths” by Kristin Nador (http://www.flickr.com/photos/kristinnador/7744274382/)
“Reese’s Pieces” by Dave Brown (http://www.flickr.com/photos/taids/2143865543/)
“Frank on the main wall” by Justin Johnson (http://www.flickr.com/photos/justinjohnsen/4512815628/)   71

More Related Content

What's hot

Brkaci 1002
Brkaci 1002Brkaci 1002
Brkaci 1002ccherel
 
Project loon report in ieee format
Project loon report in ieee formatProject loon report in ieee format
Project loon report in ieee formatsahithi reddy
 
Presentation(group j)implementing trustworthy computing by Sundas Ilyas
Presentation(group j)implementing  trustworthy computing by Sundas IlyasPresentation(group j)implementing  trustworthy computing by Sundas Ilyas
Presentation(group j)implementing trustworthy computing by Sundas IlyasSundas Kayani
 
Quantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdf
Quantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdfQuantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdf
Quantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdfMiguelFernandoBarrio
 
Network defenses
Network defensesNetwork defenses
Network defensesG Prachi
 
Cisco IT and ThousandEyes
Cisco IT and ThousandEyesCisco IT and ThousandEyes
Cisco IT and ThousandEyesThousandEyes
 
Hybrid Integration
Hybrid IntegrationHybrid Integration
Hybrid IntegrationBizTalk360
 
Cyber attacks and IT security management in 2025
Cyber attacks and IT security management in 2025Cyber attacks and IT security management in 2025
Cyber attacks and IT security management in 2025Radar Cyber Security
 
Setting up VPN between F5 LTM & ASA
Setting up VPN between F5 LTM & ASASetting up VPN between F5 LTM & ASA
Setting up VPN between F5 LTM & ASADhruv Sharma
 
Chapter 1 Introduction to Security
Chapter 1 Introduction to SecurityChapter 1 Introduction to Security
Chapter 1 Introduction to SecurityDr. Ahmed Al Zaidy
 
4.detection of fake news through implementation of data science application
4.detection of fake news through implementation of data science application4.detection of fake news through implementation of data science application
4.detection of fake news through implementation of data science applicationVenkat Projects
 
Mqtt – a protocol for the internet of things
Mqtt – a protocol for the internet of thingsMqtt – a protocol for the internet of things
Mqtt – a protocol for the internet of thingsRahul Gupta
 
Computer Ethics Presentation
Computer Ethics PresentationComputer Ethics Presentation
Computer Ethics Presentationkatespeach
 
AI in Telecom: How artificial intelligence is reshaping the vision of telco i...
AI in Telecom: How artificial intelligence is reshaping the vision of telco i...AI in Telecom: How artificial intelligence is reshaping the vision of telco i...
AI in Telecom: How artificial intelligence is reshaping the vision of telco i...Data Driven Innovation
 

What's hot (20)

Brkaci 1002
Brkaci 1002Brkaci 1002
Brkaci 1002
 
Project loon report in ieee format
Project loon report in ieee formatProject loon report in ieee format
Project loon report in ieee format
 
Presentation(group j)implementing trustworthy computing by Sundas Ilyas
Presentation(group j)implementing  trustworthy computing by Sundas IlyasPresentation(group j)implementing  trustworthy computing by Sundas Ilyas
Presentation(group j)implementing trustworthy computing by Sundas Ilyas
 
Quantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdf
Quantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdfQuantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdf
Quantum SD-WAN - High Level Customer PPT - 1-Mar-2023.pdf
 
Smart Memory ppt
Smart Memory pptSmart Memory ppt
Smart Memory ppt
 
Fortinet k
Fortinet kFortinet k
Fortinet k
 
Network defenses
Network defensesNetwork defenses
Network defenses
 
Cisco IT and ThousandEyes
Cisco IT and ThousandEyesCisco IT and ThousandEyes
Cisco IT and ThousandEyes
 
Hybrid Integration
Hybrid IntegrationHybrid Integration
Hybrid Integration
 
Cyber attacks and IT security management in 2025
Cyber attacks and IT security management in 2025Cyber attacks and IT security management in 2025
Cyber attacks and IT security management in 2025
 
Setting up VPN between F5 LTM & ASA
Setting up VPN between F5 LTM & ASASetting up VPN between F5 LTM & ASA
Setting up VPN between F5 LTM & ASA
 
Chapter 1 Introduction to Security
Chapter 1 Introduction to SecurityChapter 1 Introduction to Security
Chapter 1 Introduction to Security
 
Cyber Crime & Security
Cyber Crime & SecurityCyber Crime & Security
Cyber Crime & Security
 
4.detection of fake news through implementation of data science application
4.detection of fake news through implementation of data science application4.detection of fake news through implementation of data science application
4.detection of fake news through implementation of data science application
 
Mqtt – a protocol for the internet of things
Mqtt – a protocol for the internet of thingsMqtt – a protocol for the internet of things
Mqtt – a protocol for the internet of things
 
Cyber security
Cyber securityCyber security
Cyber security
 
Fortigate Training
Fortigate TrainingFortigate Training
Fortigate Training
 
EENA 2018 - Advanced Mobile Location - AML
EENA 2018 - Advanced Mobile Location - AML  EENA 2018 - Advanced Mobile Location - AML
EENA 2018 - Advanced Mobile Location - AML
 
Computer Ethics Presentation
Computer Ethics PresentationComputer Ethics Presentation
Computer Ethics Presentation
 
AI in Telecom: How artificial intelligence is reshaping the vision of telco i...
AI in Telecom: How artificial intelligence is reshaping the vision of telco i...AI in Telecom: How artificial intelligence is reshaping the vision of telco i...
AI in Telecom: How artificial intelligence is reshaping the vision of telco i...
 

Viewers also liked

Rethinking the Mobile Web by Yiibu
Rethinking the Mobile Web by YiibuRethinking the Mobile Web by Yiibu
Rethinking the Mobile Web by YiibuBryan Rieger
 
Hacking the next
Hacking the nextHacking the next
Hacking the nextaeioux
 
CSS3: Using media queries to improve the web site experience
CSS3: Using media queries to improve the web site experienceCSS3: Using media queries to improve the web site experience
CSS3: Using media queries to improve the web site experienceZoe Gillenwater
 
Accessible UX: Beyond the checklist to great experiences
Accessible UX: Beyond the checklist to great experiencesAccessible UX: Beyond the checklist to great experiences
Accessible UX: Beyond the checklist to great experiencesWhitney Quesenbery
 
Understanding & Designing for the Mobile Web
Understanding & Designing for the Mobile WebUnderstanding & Designing for the Mobile Web
Understanding & Designing for the Mobile WebWebFX
 
Deconstructing delight
Deconstructing delightDeconstructing delight
Deconstructing delightDana Chisnell
 
Building Responsive Layouts
Building Responsive LayoutsBuilding Responsive Layouts
Building Responsive LayoutsZoe Gillenwater
 
Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Salesforce Developers
 
深入淺出RWD自適應網頁設計
深入淺出RWD自適應網頁設計深入淺出RWD自適應網頁設計
深入淺出RWD自適應網頁設計Marie Chang
 
Android vs iPhone - Differences in UI Patterns and Design
Android vs iPhone - Differences in UI Patterns and DesignAndroid vs iPhone - Differences in UI Patterns and Design
Android vs iPhone - Differences in UI Patterns and DesignJeremy Johnson
 
Design Process in the Responsive Age
Design Process in the Responsive AgeDesign Process in the Responsive Age
Design Process in the Responsive AgePon Kattera
 
From Desktop to Home: Optimizing for Voice
From Desktop to Home: Optimizing for VoiceFrom Desktop to Home: Optimizing for Voice
From Desktop to Home: Optimizing for VoicePeter "Dr. Pete" Meyers
 

Viewers also liked (15)

Rethinking the Mobile Web by Yiibu
Rethinking the Mobile Web by YiibuRethinking the Mobile Web by Yiibu
Rethinking the Mobile Web by Yiibu
 
Hacking the next
Hacking the nextHacking the next
Hacking the next
 
CSS3: Using media queries to improve the web site experience
CSS3: Using media queries to improve the web site experienceCSS3: Using media queries to improve the web site experience
CSS3: Using media queries to improve the web site experience
 
Accessible UX: Beyond the checklist to great experiences
Accessible UX: Beyond the checklist to great experiencesAccessible UX: Beyond the checklist to great experiences
Accessible UX: Beyond the checklist to great experiences
 
Understanding & Designing for the Mobile Web
Understanding & Designing for the Mobile WebUnderstanding & Designing for the Mobile Web
Understanding & Designing for the Mobile Web
 
Deconstructing delight
Deconstructing delightDeconstructing delight
Deconstructing delight
 
The World of Google: US Vs. Europe
The World of Google: US Vs. EuropeThe World of Google: US Vs. Europe
The World of Google: US Vs. Europe
 
SLDS and Lightning Components
SLDS and Lightning ComponentsSLDS and Lightning Components
SLDS and Lightning Components
 
Building Responsive Layouts
Building Responsive LayoutsBuilding Responsive Layouts
Building Responsive Layouts
 
響應式網頁教學
響應式網頁教學響應式網頁教學
響應式網頁教學
 
Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17
 
深入淺出RWD自適應網頁設計
深入淺出RWD自適應網頁設計深入淺出RWD自適應網頁設計
深入淺出RWD自適應網頁設計
 
Android vs iPhone - Differences in UI Patterns and Design
Android vs iPhone - Differences in UI Patterns and DesignAndroid vs iPhone - Differences in UI Patterns and Design
Android vs iPhone - Differences in UI Patterns and Design
 
Design Process in the Responsive Age
Design Process in the Responsive AgeDesign Process in the Responsive Age
Design Process in the Responsive Age
 
From Desktop to Home: Optimizing for Voice
From Desktop to Home: Optimizing for VoiceFrom Desktop to Home: Optimizing for Voice
From Desktop to Home: Optimizing for Voice
 

Similar to Building Responsive Layouts

The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS LayoutZoe Gillenwater
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)elliando dias
 
Flexbox every developers dream
Flexbox every developers dreamFlexbox every developers dream
Flexbox every developers dream2019gracesmith
 
JavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy FowlerJavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy FowlerStephen Chin
 
What is grid system
What is grid systemWhat is grid system
What is grid systemchetankane
 
Mobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image CardMobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image CardAndiNurkholis1
 
Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...
Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...
Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...BookNet Canada
 
Solving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJSSolving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJSRachel Andrew
 
Solving Layout Problems With CSS Grid and Friends
Solving Layout Problems With CSS Grid and FriendsSolving Layout Problems With CSS Grid and Friends
Solving Layout Problems With CSS Grid and FriendsFITC
 
Solving Layout Problems with CSS Grid & Friends - WEBU17
Solving Layout Problems with CSS Grid & Friends - WEBU17Solving Layout Problems with CSS Grid & Friends - WEBU17
Solving Layout Problems with CSS Grid & Friends - WEBU17Rachel Andrew
 
404.ie: Solving Layout Problems with CSS Grid & Friends
404.ie: Solving Layout Problems with CSS Grid & Friends404.ie: Solving Layout Problems with CSS Grid & Friends
404.ie: Solving Layout Problems with CSS Grid & FriendsRachel Andrew
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using cssDhairya Joshi
 

Similar to Building Responsive Layouts (20)

The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS Layout
 
CSS3 Layout
CSS3 LayoutCSS3 Layout
CSS3 Layout
 
Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)Compass And Sass(Tim Riley)
Compass And Sass(Tim Riley)
 
Ppt ch06
Ppt ch06Ppt ch06
Ppt ch06
 
Ppt ch06
Ppt ch06Ppt ch06
Ppt ch06
 
Flexbox every developers dream
Flexbox every developers dreamFlexbox every developers dream
Flexbox every developers dream
 
JavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy FowlerJavaFX Layout Secrets with Amy Fowler
JavaFX Layout Secrets with Amy Fowler
 
CSS in all its Glory
CSS in all its GloryCSS in all its Glory
CSS in all its Glory
 
Layouts
Layouts Layouts
Layouts
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
What is grid system
What is grid systemWhat is grid system
What is grid system
 
Mobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image CardMobile Programming - 4 Modifiers and Image Card
Mobile Programming - 4 Modifiers and Image Card
 
Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...
Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...
Faking a Grid - Franco Alvarado (Macmillan Learning), Betsy Granger (Macmilla...
 
Solving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJSSolving Layout Problems with CSS Grid & Friends - NordicJS
Solving Layout Problems with CSS Grid & Friends - NordicJS
 
Solving Layout Problems With CSS Grid and Friends
Solving Layout Problems With CSS Grid and FriendsSolving Layout Problems With CSS Grid and Friends
Solving Layout Problems With CSS Grid and Friends
 
Solving Layout Problems with CSS Grid & Friends - WEBU17
Solving Layout Problems with CSS Grid & Friends - WEBU17Solving Layout Problems with CSS Grid & Friends - WEBU17
Solving Layout Problems with CSS Grid & Friends - WEBU17
 
CSS
CSSCSS
CSS
 
CSS Systems
CSS SystemsCSS Systems
CSS Systems
 
404.ie: Solving Layout Problems with CSS Grid & Friends
404.ie: Solving Layout Problems with CSS Grid & Friends404.ie: Solving Layout Problems with CSS Grid & Friends
404.ie: Solving Layout Problems with CSS Grid & Friends
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
 

More from Zoe Gillenwater

Using Flexbox Today (Frontier Conf 2016)
Using Flexbox Today (Frontier Conf 2016)Using Flexbox Today (Frontier Conf 2016)
Using Flexbox Today (Frontier Conf 2016)Zoe Gillenwater
 
Using Flexbox Today (Generate Sydney 2016)
Using Flexbox Today (Generate Sydney 2016)Using Flexbox Today (Generate Sydney 2016)
Using Flexbox Today (Generate Sydney 2016)Zoe Gillenwater
 
Using Flexbox Today (CSS Summit 2016)
Using Flexbox Today (CSS Summit 2016)Using Flexbox Today (CSS Summit 2016)
Using Flexbox Today (CSS Summit 2016)Zoe Gillenwater
 
Using Flexbox Today (Frontend United 2016)
Using Flexbox Today (Frontend United 2016)Using Flexbox Today (Frontend United 2016)
Using Flexbox Today (Frontend United 2016)Zoe Gillenwater
 
Show vs. Tell in UX Design (Front in Amsterdam)
Show vs. Tell in UX Design (Front in Amsterdam)Show vs. Tell in UX Design (Front in Amsterdam)
Show vs. Tell in UX Design (Front in Amsterdam)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
 
Responsive Flexbox Inspiration (Responsive Day Out)
Responsive Flexbox Inspiration (Responsive Day Out)Responsive Flexbox Inspiration (Responsive Day Out)
Responsive Flexbox Inspiration (Responsive Day Out)Zoe Gillenwater
 
Enhancing Responsiveness With Flexbox (CSS Day)
Enhancing Responsiveness With Flexbox (CSS Day)Enhancing Responsiveness With Flexbox (CSS Day)
Enhancing Responsiveness With Flexbox (CSS Day)Zoe Gillenwater
 
CSS Lessons Learned the Hard Way (ConvergeSE)
CSS Lessons Learned the Hard Way (ConvergeSE)CSS Lessons Learned the Hard Way (ConvergeSE)
CSS Lessons Learned the Hard Way (ConvergeSE)Zoe Gillenwater
 
Enhancing Responsiveness With Flexbox (Smashing Conference)
Enhancing Responsiveness With Flexbox (Smashing Conference)Enhancing Responsiveness With Flexbox (Smashing Conference)
Enhancing Responsiveness With Flexbox (Smashing Conference)Zoe Gillenwater
 
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
 
CSS Lessons Learned the Hard Way (Beyond Tellerand)
CSS Lessons Learned the Hard Way (Beyond Tellerand)CSS Lessons Learned the Hard Way (Beyond Tellerand)
CSS Lessons Learned the Hard Way (Beyond Tellerand)Zoe Gillenwater
 
CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)Zoe Gillenwater
 
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)Zoe Gillenwater
 
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
 
Just One (CSS Dev Conference keynote)
Just One (CSS Dev Conference keynote)Just One (CSS Dev Conference keynote)
Just One (CSS Dev Conference keynote)Zoe Gillenwater
 
Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)Zoe Gillenwater
 
Putting Flexbox into Practice
Putting Flexbox into PracticePutting Flexbox into Practice
Putting Flexbox into PracticeZoe Gillenwater
 
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignZoe Gillenwater
 

More from Zoe Gillenwater (20)

Using Flexbox Today (Frontier Conf 2016)
Using Flexbox Today (Frontier Conf 2016)Using Flexbox Today (Frontier Conf 2016)
Using Flexbox Today (Frontier Conf 2016)
 
Using Flexbox Today (Generate Sydney 2016)
Using Flexbox Today (Generate Sydney 2016)Using Flexbox Today (Generate Sydney 2016)
Using Flexbox Today (Generate Sydney 2016)
 
Using Flexbox Today (CSS Summit 2016)
Using Flexbox Today (CSS Summit 2016)Using Flexbox Today (CSS Summit 2016)
Using Flexbox Today (CSS Summit 2016)
 
Using Flexbox Today (Frontend United 2016)
Using Flexbox Today (Frontend United 2016)Using Flexbox Today (Frontend United 2016)
Using Flexbox Today (Frontend United 2016)
 
Show vs. Tell in UX Design (Front in Amsterdam)
Show vs. Tell in UX Design (Front in Amsterdam)Show vs. Tell in UX Design (Front in Amsterdam)
Show vs. Tell in UX Design (Front in Amsterdam)
 
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)
 
Responsive Flexbox Inspiration (Responsive Day Out)
Responsive Flexbox Inspiration (Responsive Day Out)Responsive Flexbox Inspiration (Responsive Day Out)
Responsive Flexbox Inspiration (Responsive Day Out)
 
Enhancing Responsiveness With Flexbox (CSS Day)
Enhancing Responsiveness With Flexbox (CSS Day)Enhancing Responsiveness With Flexbox (CSS Day)
Enhancing Responsiveness With Flexbox (CSS Day)
 
CSS Lessons Learned the Hard Way (ConvergeSE)
CSS Lessons Learned the Hard Way (ConvergeSE)CSS Lessons Learned the Hard Way (ConvergeSE)
CSS Lessons Learned the Hard Way (ConvergeSE)
 
Enhancing Responsiveness With Flexbox (Smashing Conference)
Enhancing Responsiveness With Flexbox (Smashing Conference)Enhancing Responsiveness With Flexbox (Smashing Conference)
Enhancing Responsiveness With Flexbox (Smashing 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)
 
CSS Lessons Learned the Hard Way (Beyond Tellerand)
CSS Lessons Learned the Hard Way (Beyond Tellerand)CSS Lessons Learned the Hard Way (Beyond Tellerand)
CSS Lessons Learned the Hard Way (Beyond Tellerand)
 
CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)CSS Lessons Learned the Hard Way (Generate Conf)
CSS Lessons Learned the Hard Way (Generate Conf)
 
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)
 
Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)Leveling Up with Flexbox (Smashing Conference)
Leveling Up with Flexbox (Smashing Conference)
 
Just One (CSS Dev Conference keynote)
Just One (CSS Dev Conference keynote)Just One (CSS Dev Conference keynote)
Just One (CSS Dev Conference keynote)
 
Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)Putting Flexbox into Practice (Fronteers)
Putting Flexbox into Practice (Fronteers)
 
Putting Flexbox into Practice
Putting Flexbox into PracticePutting Flexbox into Practice
Putting Flexbox into Practice
 
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive Design
 
Web Accessibility
Web AccessibilityWeb Accessibility
Web Accessibility
 

Recently uploaded

(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一Fi sss
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdfvaibhavkanaujia
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...katerynaivanenko1
 
CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10
CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10
CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10uasjlagroup
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxmapanig881
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一F dds
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricksabhishekparmar618
 
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一Fi L
 
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCRdollysharma2066
 
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfAayushChavan5
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一diploma 1
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造kbdhl05e
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一z xss
 
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree 毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree ttt fff
 
Dubai Calls Girl Tapes O525547819 Real Tapes Escort Services Dubai
Dubai Calls Girl Tapes O525547819 Real Tapes Escort Services DubaiDubai Calls Girl Tapes O525547819 Real Tapes Escort Services Dubai
Dubai Calls Girl Tapes O525547819 Real Tapes Escort Services Dubaikojalkojal131
 
Design Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryDesign Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryWilliamVickery6
 

Recently uploaded (20)

(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdf
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
 
Call Girls in Pratap Nagar, 9953056974 Escort Service
Call Girls in Pratap Nagar,  9953056974 Escort ServiceCall Girls in Pratap Nagar,  9953056974 Escort Service
Call Girls in Pratap Nagar, 9953056974 Escort Service
 
CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10
CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10
CREATING A POSITIVE SCHOOL CULTURE CHAPTER 10
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptx
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricks
 
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
办理学位证(TheAuckland证书)新西兰奥克兰大学毕业证成绩单原版一比一
 
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
 
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdf
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
 
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree 毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲弗林德斯大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Dubai Calls Girl Tapes O525547819 Real Tapes Escort Services Dubai
Dubai Calls Girl Tapes O525547819 Real Tapes Escort Services DubaiDubai Calls Girl Tapes O525547819 Real Tapes Escort Services Dubai
Dubai Calls Girl Tapes O525547819 Real Tapes Escort Services Dubai
 
Design Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryDesign Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William Vickery
 

Building Responsive Layouts

  • 1. Building Responsive Layouts by Zoe Mickley Gillenwater @zomigi zomigi.com December 5, 2012 CSS Dev Conf
  • 3. I don’t use a mobile phone
  • 4. I have a process for eating these
  • 5. why responsive web design works 5
  • 6.  what why responsive web design means 6
  • 7.  ? what why how to do responsive web design 7
  • 8. fluid/liquid layout uses percentage widths to adapt to size of viewport 8
  • 9. Look at this! This is so tough! I'm in such peril way up here! 9
  • 11. How do we make this fluid? 11
  • 12. Start with fluid wrapper 12
  • 13. Add opposing floats inside 13
  • 14. 3 cols with poor source order 14
  • 15. Nest 2-col layout in 2-col layout 15
  • 17. Determining nested widths width of column you want to match ÷ width of parent column = width of nested column 17
  • 18. Determining nested widths width of column you want to match ÷ width of parent column = width of nested column target ÷ context = result 18
  • 19. Determining nested widths width of column you want to match ÷ width of parent column = width of nested column target ÷ context = result 20 ÷ 80 = .25 which means 25% 19
  • 21. What about fluid grids? 21
  • 22. Width of this nested block? 22
  • 23. Well that's not right… 23
  • 24. To the laboratory! width of column you want to match ÷ width of parent column = width of nested column target ÷ context = result 25 ÷ 62.5 = .4 which means 40% 24
  • 26. ? widths spacing between and in fluid columns 26
  • 27. Leave a gap via widths 27
  • 28. Declaring fluid margin/padding • Adjust widths so everything adds to 100% • For IE 6/7, make it 99%: avoids problems due to rounding % to px • Nesting affects margin/padding values too • Use target÷context formula to match outer spacing with inner spacing 28
  • 29. Using box-sizing • Makes px & em margin/padding on fluid layout easy • Standard box model • box-sizing: content-box • Padding & border added on to width/height • New box model • box-sizing: border-box • Padding & border subtracted from width/height 29
  • 30. Fluid grid, fixed-width spacing .column { float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0 20px; Subtracted } from width in border-box box model 30
  • 31. Use border as faux margin .column { float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0 20px; border-left: 10px solid rgba(0,0,0,0); -moz-background-clip: padding-box; -webkit-background-clip: padding-box; background-clip: padding-box; } Prevents background from displaying under border 31
  • 32. Negate “margin” at start of row .column { float: left; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0 20px; border-left: 10px solid rgba(0,0,0,0); -moz-background-clip: padding-box; -webkit-background-clip: padding-box; background-clip: padding-box; } .row { margin-left: -10px; Removes gap to } left of first column 32
  • 33. Fix box-sizing in IE 7 and 6 • Feed different dimensions based on content-box-model, or • Use Christian Schaefer's box-sizing polyfill https://github.com/Schepp/box-sizing-polyfill .column { box-sizing: border-box; *behavior: url(boxsizing.htc); } 33
  • 35. ? fluid hybrid one+ column flexible, one+ not 35
  • 36. Hybrid layout options • Easy: sidebars first in HTML • Float sidebars, main content moves up between floats • But usually not option in responsive design • Tricky: main content first in HTML • Need to float it, but with what width? • One solution: negative margins 36
  • 38. Add wrapper with padding #content-wrapper { padding-right: 290px; } 38
  • 39. Lay out main content div #content-main { float: left; width: 100%; } 39
  • 40. Float sidebar #content-secondary { float: right; width: 250px; } 40
  • 41. A positive right margin 150px 41
  • 42. A negative right margin -150px 42
  • 43. Pull sidebar into gap #content-secondary { float: right; width: 250px; margin-right: -290px; Matches } wrapper’s right padding, just negative 43
  • 44. Success! 44
  • 45. To make sidebar show in IE 6 #content-wrapper { zoom: 1; Adds hasLayout } #content-main, #content-secondary { display: inline; Hell if I know, } it just works 45
  • 46. 3-column hybrid layout • Nest one 2-column layout inside another • Components of each layout: 1. Wrapper with padding on one side 2. Fixed-width sidebar • Same width as padding (or smaller) • Floated same direction as padding • Negative margin matching padding on same side 3. Fluid column • Floated opposite direction • Width 100% 46
  • 47. ? fluid layout media queries feed different styles based on viewport size 47
  • 48. Choosing default styles • Start "mobile," layer on wider styles? • Start "desktop," layer on narrower styles? • Start somewhere in between, layer on both? • Learn full pros/cons: www.zomigi.com/blog/essential-considerations- crafting-quality-media-queries 48
  • 50. Wide-screen media query /*all the other styles up here*/ @media screen and (min-width: 1200px) { /*styles for larger screens in here*/ } 50
  • 51. Add third column @media screen and (min-width: 1200px) { #nav-main { position: fixed; top: 136px; width: 13%; margin: 0; } #content-main { width: 58%; margin-left: 18%; } #content-secondary { width: 20%; } } 51
  • 52. Style nav as vertical menu @media screen and (min-width: 1200px) { ... #nav-main li { float: none; Stack links margin: 0; } #nav-main a { -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; Less tab-like } } 52
  • 54. Small-screen media query /*all the other styles up here*/ @media screen and (max-width: 760px) { /*styles for smaller screens in here*/ } 54
  • 55. Things to fix too few words per line, so make all one column each too narrow, so stack instead and put pic on left 55
  • 57. Mobile media query /*all the other styles up here*/ @media screen and (max-width: 550px) { /*styles for tiny screens in here*/ } 57
  • 58. Non-overlapping version @media screen and (min-width: 551px) and (max-width: 760px) { /*styles for small screens in here*/ } @media screen and (max-width: 550px) { /*styles for tiny screens in here*/ } 58
  • 59. Changing to single column @media screen and (max-width: 550px) { #content-main, #content-secondary, #about, #credits { float: none; width: 100%; } } 59
  • 60. Changing feature images @media screen and (max-width: 550px) { ... .feature { padding-left: 70px; } #feature-candy { background-image: url(icon_candy_64.png); } #feature-pastry { background-image: url(icon_pastry_64.png); } #feature-dessert { background-image: url(icon_dessert_64.png); } } 60
  • 62. Viewport meta tag Forces mobile devices to scale viewport to actual device width <meta name="viewport" content="width=device-width"> 62
  • 63. Fix iOS zoom problems <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="ios-orientationchange-fix.js"> • Add initial-scale=1 to make page reflow when you switch to landscape • Add script to fix over-zoom bug that crops right side of page when you switch • See http://filamentgroup.com/lab/a_fix_for_ the_ios_orientationchange_zoom_bug/ 63
  • 64. Double-up inside the CSS Add @viewport rule, upcoming standard, inside style sheet: @-moz-viewport{ width:device-width } @-ms-viewport{ width:device-width } @-o-viewport{ width:device-width } @-webkit-viewport{ width:device-width } @viewport{ width:device-width } 64
  • 65. conditional comments or JavaScript to deal with IE 8 and earlier 65
  • 66. Conditional comments • Split styles into separate sheets and feed applicable sheet to IE based on whether it's IE on desktop or mobile • Approach varies based on which set of styles are your default 66
  • 67. Conditional comment when desktop styles are default Feed IE Mobile 7 media query sheet: <link rel="stylesheet" href="global.css" media="all"> <link rel="stylesheet" href="mobile.css" media="all and (max-width: 700px)"> <!--[if IEMobile 7]> <link rel="stylesheet" href="mobile.css" media="all"> <![endif]--> Source: http://blogs.msdn.com/b/iemobile/archive/2010/12/08/targeting-mobile- optimized-css-at-windows-phone-7.aspx 67
  • 68. Conditional comment when mobile styles are default Feed older IE media query sheet, hide from IE Mobile 7: <link rel="stylesheet" href="global.css" media="all"> <link rel="stylesheet" href="desktop.css" media="all and (min-width: 700px)"> <!--[if (lt IE 9)&(!IEMobile 7)]> <link rel="stylesheet" href="desktop.css" media="all"> <![endif]--> Source: http://adactio.com/journal/4494/ 68
  • 69. Pre-fab JavaScript for non- supporting browsers • Simply add one of these scripts: • Respond: https://github.com/scottjehl/Respond • css3-mediaqueries.js: http://code.google.com/p/css3-mediaqueries-js/ • Avoid extra HTTP request for non-old-IE browsers using conditional comments: <!--[if (lt IE 9)&(!IEMobile 7)]> <script src="respond.min.js"></script> <![endif]--> 69
  • 71. Learn more Download slides and get links at http://bit.ly/rwdlayout Zoe Mickley Gillenwater @zomigi design@zomigi.com zomigi.com | stunningcss3.com | flexiblewebbook.com Photo credits: “023 Tape measure 006” by Steve James (http://www.flickr.com/photos/steeljam/3350481764/) “Phone Booths” by Kristin Nador (http://www.flickr.com/photos/kristinnador/7744274382/) “Reese’s Pieces” by Dave Brown (http://www.flickr.com/photos/taids/2143865543/) “Frank on the main wall” by Justin Johnson (http://www.flickr.com/photos/justinjohnsen/4512815628/) 71