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

Composition and layout
Composition and layoutComposition and layout
Composition and layoutABY AUGUSTINE
 
Typography presentation
Typography presentationTypography presentation
Typography presentationGreg Sarles
 
Building the Metaverse
Building the MetaverseBuilding the Metaverse
Building the MetaverseJon Radoff
 
Grid Systems: Building Blocks to a Better User Experience
Grid Systems: Building Blocks to a Better User ExperienceGrid Systems: Building Blocks to a Better User Experience
Grid Systems: Building Blocks to a Better User ExperienceDustin DiTommaso
 
Chapter 1 - Multimedia Fundamentals
Chapter 1 - Multimedia FundamentalsChapter 1 - Multimedia Fundamentals
Chapter 1 - Multimedia FundamentalsPratik Pradhan
 
Graphic and Web Design Principles
Graphic and Web Design Principles                      Graphic and Web Design Principles
Graphic and Web Design Principles Rob Nunez
 
Photoshop terminology
Photoshop terminologyPhotoshop terminology
Photoshop terminologyalisonpruett
 
Graphic design by Muhammad Mujeeb Riaz
Graphic design by Muhammad Mujeeb RiazGraphic design by Muhammad Mujeeb Riaz
Graphic design by Muhammad Mujeeb RiazMujeeb Riaz
 
Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...
Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...
Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...IRJET Journal
 
Netflix brand management
Netflix brand managementNetflix brand management
Netflix brand managementArushi Goel
 
Netflix business marketpresentation_economics
Netflix business marketpresentation_economicsNetflix business marketpresentation_economics
Netflix business marketpresentation_economicsGraysonMeeks
 
Workshop Graphic Designing - Basics and Principles
Workshop Graphic Designing - Basics and PrinciplesWorkshop Graphic Designing - Basics and Principles
Workshop Graphic Designing - Basics and PrinciplesEbtihaj khan
 
Basic concept of Graphic Design
Basic concept of Graphic DesignBasic concept of Graphic Design
Basic concept of Graphic DesignAshikul Islam
 
Netflix branding stumbles
Netflix branding stumblesNetflix branding stumbles
Netflix branding stumblesRavi Khatri
 
Modern Graphic Design
Modern Graphic DesignModern Graphic Design
Modern Graphic DesignYekaterina22
 
Graphic Designing Presentation (Tips & Tricks)
Graphic Designing Presentation (Tips & Tricks)Graphic Designing Presentation (Tips & Tricks)
Graphic Designing Presentation (Tips & Tricks)RJNithin
 

What's hot (20)

Composition and layout
Composition and layoutComposition and layout
Composition and layout
 
Typography presentation
Typography presentationTypography presentation
Typography presentation
 
Multimedia Basics
Multimedia BasicsMultimedia Basics
Multimedia Basics
 
Building the Metaverse
Building the MetaverseBuilding the Metaverse
Building the Metaverse
 
Grid Systems: Building Blocks to a Better User Experience
Grid Systems: Building Blocks to a Better User ExperienceGrid Systems: Building Blocks to a Better User Experience
Grid Systems: Building Blocks to a Better User Experience
 
Chapter 1 - Multimedia Fundamentals
Chapter 1 - Multimedia FundamentalsChapter 1 - Multimedia Fundamentals
Chapter 1 - Multimedia Fundamentals
 
typography
 typography typography
typography
 
Principles of Design
Principles of DesignPrinciples of Design
Principles of Design
 
Graphic and Web Design Principles
Graphic and Web Design Principles                      Graphic and Web Design Principles
Graphic and Web Design Principles
 
Photoshop terminology
Photoshop terminologyPhotoshop terminology
Photoshop terminology
 
Graphic design by Muhammad Mujeeb Riaz
Graphic design by Muhammad Mujeeb RiazGraphic design by Muhammad Mujeeb Riaz
Graphic design by Muhammad Mujeeb Riaz
 
Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...
Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...
Analysis and Prediction of Diabetes Diseases using Machine Learning Algorithm...
 
Netflix brand management
Netflix brand managementNetflix brand management
Netflix brand management
 
Netflix business marketpresentation_economics
Netflix business marketpresentation_economicsNetflix business marketpresentation_economics
Netflix business marketpresentation_economics
 
Workshop Graphic Designing - Basics and Principles
Workshop Graphic Designing - Basics and PrinciplesWorkshop Graphic Designing - Basics and Principles
Workshop Graphic Designing - Basics and Principles
 
Basic concept of Graphic Design
Basic concept of Graphic DesignBasic concept of Graphic Design
Basic concept of Graphic Design
 
Netflix branding stumbles
Netflix branding stumblesNetflix branding stumbles
Netflix branding stumbles
 
Modern Graphic Design
Modern Graphic DesignModern Graphic Design
Modern Graphic Design
 
I - Mode Technology
I - Mode TechnologyI - Mode Technology
I - Mode Technology
 
Graphic Designing Presentation (Tips & Tricks)
Graphic Designing Presentation (Tips & Tricks)Graphic Designing Presentation (Tips & Tricks)
Graphic Designing Presentation (Tips & Tricks)
 

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

在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证nhjeo1gg
 
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一Fi sss
 
Design Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryDesign Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryWilliamVickery6
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
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
 
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
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdfvaibhavkanaujia
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)jennyeacort
 
Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.Mookuthi
 
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts ServiceCall Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Servicejennyeacort
 
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一F La
 
办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一
办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一
办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一Fi L
 
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
 
原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
group_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdfgroup_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdfneelspinoy
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfAayushChavan5
 
Call Girls Meghani Nagar 7397865700 Independent Call Girls
Call Girls Meghani Nagar 7397865700  Independent Call GirlsCall Girls Meghani Nagar 7397865700  Independent Call Girls
Call Girls Meghani Nagar 7397865700 Independent Call Girlsssuser7cb4ff
 
How to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AIHow to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AIyuj
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一F dds
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一z xss
 

Recently uploaded (20)

在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
 
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
 
Design Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryDesign Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William Vickery
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
 
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
 
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
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdf
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
 
Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.Mookuthi is an artisanal nose ornament brand based in Madras.
Mookuthi is an artisanal nose ornament brand based in Madras.
 
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts ServiceCall Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
Call Girls in Ashok Nagar Delhi ✡️9711147426✡️ Escorts Service
 
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
 
办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一
办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一
办理学位证(NUS证书)新加坡国立大学毕业证成绩单原版一比一
 
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
 
原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档
原版1:1定制堪培拉大学毕业证(UC毕业证)#文凭成绩单#真实留信学历认证永久存档
 
group_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdfgroup_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdf
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdf
 
Call Girls Meghani Nagar 7397865700 Independent Call Girls
Call Girls Meghani Nagar 7397865700  Independent Call GirlsCall Girls Meghani Nagar 7397865700  Independent Call Girls
Call Girls Meghani Nagar 7397865700 Independent Call Girls
 
How to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AIHow to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AI
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
 

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