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



August 28, 2012
Responsive Web Design Summit
What I do
      Books                         Web
      Stunning CSS3:                Accessibility
      A Project-based Guide to      specialist at AT&T
      the Latest in CSS
                                    Visual designer
      www.stunningcss3.com
                                    CSS developer
                                    and consultant
      Flexible Web Design:
      Creating Liquid and Elastic
      Layouts with CSS
      www.flexiblewebbook.com

                                                         2

          why
responsive web design works



                              3
         
 what      why
responsive web design means



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



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



                                  6
hybrid layout
one+ column flexible, one+ not




                                 7
responsive web design
fluid layout and flexible images
  adapted with media queries
   www.alistapart.com/articles/responsive-web-design/




                                                        8
adaptive layouts
 multiple fixed-width layouts
swapped with media queries
www.netmagazine.com/tutorials/adaptive-layouts-media-queries




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




                    10
Oh, wait…




            11
How do
we make
this fluid?




              12
Start with fluid wrapper




                           13
Add opposing floats inside




                             14
3-column layout: nest 2-column
layout inside 2-column 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 up to just
  under 100%
  • 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 fixed-width 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;
}




                                    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;
}
.row {
  margin-left: -10px;
}
                                           31
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);
  }



                                                  32
I recommend gridpak.com




                          33
                     ?
  fluid               hybrid
main column fluid, sidebar fixed



                                   34
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




                                                  35
Fixed-width
sidebar
starting point




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




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




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




                       39
A positive right margin



                   150px




                           40
A negative right margin



                      -150px




                               41
Add negative right margin
matching wrapper's right padding
#content-secondary {
  float: right;
  width: 250px;
  margin-right: -290px;
}




                               42
Success!




           43
To make sidebar show in IE 6
#content-wrapper {
  zoom: 1;
}
#content-main,
#content-secondary {
  display: inline;
}




                               44
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%

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

                                  46
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




                                                    47
Starting
in the
middle




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

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




                                            49
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%; }
}
                                          50
Style nav as vertical menu
@media screen and (min-width: 1200px) {
    ...
    #nav-main li {
        float: none;
        margin: 0;
        }
    #nav-main a {
        -moz-border-radius: 0;
        -webkit-border-radius: 0;
        border-radius: 0;
    }
}

                                          51
Wide-screen design




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

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




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




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



                          54
Narrow-
screen
design




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

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




                                          56
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*/
}




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




                                         58
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);
    }
}
                                                      59
Mobile
design




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

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




                                             61
Zoom problem in iOS
• The device-width on iOS devices always
  matches portrait width
• This means design doesn't reflow when you
  switch to landscape, but instead just zooms




                                            62
Fixing (and adding) zoom issues
• Option 1: add maximum-scale=1
 • But disables user scaling
   <meta name="viewport"
      content="width=device-width, maximum-scale=1">


• Option 2: add initial-scale=1
 • Allows user scaling
 • But triggers over-zoom/crop bug when
   changing from portrait to landscape
   <meta name="viewport"
      content="width=device-width, initial-scale=1">

                                                   63
The best way to fix zoom issues
• Option 3: add initial-scale=1 plus
  script to fix over-zoom bug
  • See http://filamentgroup.com/lab/a_fix_for_
    the_ios_orientationchange_zoom_bug/

<head>
  ...
  <meta name="viewport"
      content="width=device-width, initial-scale=1">
  <script src="ios-orientationchange-fix.js">
  ...
</head>
                                                       64
or
conditional
 comments           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://zomigi.com/blog/responsive-layouts-
presentation



Zoe Mickley Gillenwater
@zomigi
design@zomigi.com
zomigi.com | stunningcss3.com | flexiblewebbook.com

Title photo by Steve James (http://www.flickr.com/photos/steeljam/3350481764/)
Rock climbing photo by Justin Johnson (http://www.flickr.com/photos/justinjohnsen/4512815628/)   71

More Related Content

Viewers also liked

Getting Started With Php Frameworks @BCP5
Getting Started With Php Frameworks @BCP5Getting Started With Php Frameworks @BCP5
Getting Started With Php Frameworks @BCP5Amit Kumar Singh
 
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
 
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
 
Тестирование требований
Тестирование требованийТестирование требований
Тестирование требованийISsoft
 
Custom Post Type and Taxonomies in WordPress 3.x
Custom Post Type and Taxonomies in WordPress 3.xCustom Post Type and Taxonomies in WordPress 3.x
Custom Post Type and Taxonomies in WordPress 3.xAmit Kumar Singh
 
Верстка_Лекция1
Верстка_Лекция1Верстка_Лекция1
Верстка_Лекция1itc73
 
Joomla Request To Response
Joomla Request To ResponseJoomla Request To Response
Joomla Request To ResponseAmit Kumar Singh
 
Таблицы Html
Таблицы HtmlТаблицы Html
Таблицы HtmlVasya Petrov
 
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
 
17. основы css (cascading style sheets)
17. основы css (cascading style sheets)17. основы css (cascading style sheets)
17. основы css (cascading style sheets)Sergei Dubrov
 
Uwe usability evaluation
Uwe usability evaluationUwe usability evaluation
Uwe usability evaluationLon Barfield
 
Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"
Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"
Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"Yandex
 
Organisation and navigation
Organisation and navigationOrganisation and navigation
Organisation and navigationLon Barfield
 
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
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеISsoft
 

Viewers also liked (18)

Getting Started With Php Frameworks @BCP5
Getting Started With Php Frameworks @BCP5Getting Started With Php Frameworks @BCP5
Getting Started With Php Frameworks @BCP5
 
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)
 
Php Security
Php SecurityPhp Security
Php Security
 
Using Flexbox Today (Generate Sydney 2016)
Using Flexbox Today (Generate Sydney 2016)Using Flexbox Today (Generate Sydney 2016)
Using Flexbox Today (Generate Sydney 2016)
 
Тестирование требований
Тестирование требованийТестирование требований
Тестирование требований
 
Custom Post Type and Taxonomies in WordPress 3.x
Custom Post Type and Taxonomies in WordPress 3.xCustom Post Type and Taxonomies in WordPress 3.x
Custom Post Type and Taxonomies in WordPress 3.x
 
Верстка_Лекция1
Верстка_Лекция1Верстка_Лекция1
Верстка_Лекция1
 
Joomla Request To Response
Joomla Request To ResponseJoomla Request To Response
Joomla Request To Response
 
Таблицы Html
Таблицы HtmlТаблицы Html
Таблицы Html
 
Box Model
Box ModelBox Model
Box Model
 
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)
 
17. основы css (cascading style sheets)
17. основы css (cascading style sheets)17. основы css (cascading style sheets)
17. основы css (cascading style sheets)
 
Uwe usability evaluation
Uwe usability evaluationUwe usability evaluation
Uwe usability evaluation
 
How Joomla Works
How Joomla WorksHow Joomla Works
How Joomla Works
 
Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"
Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"
Сергей Бережной "Про шаблонизаторы вообще и BEMHTML в частности"
 
Organisation and navigation
Organisation and navigationOrganisation and navigation
Organisation and navigation
 
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)
 
Bdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проектеBdd and dsl как способ построения коммуникации на проекте
Bdd and dsl как способ построения коммуникации на проекте
 

Similar to Building Responsive Layouts with Fluid, Hybrid and Media Query Techniques

The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS LayoutZoe Gillenwater
 
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
 
What is grid system
What is grid systemWhat is grid system
What is grid systemchetankane
 
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
 
Top 100 Diagrams in Editable Powerpoint
Top 100 Diagrams in Editable PowerpointTop 100 Diagrams in Editable Powerpoint
Top 100 Diagrams in Editable PowerpointAurelien Domont, MBA
 
Flexbox every developers dream
Flexbox every developers dreamFlexbox every developers dream
Flexbox every developers dream2019gracesmith
 
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)Four Kitchens
 
Grids In Modern Web Design
Grids In Modern Web DesignGrids In Modern Web Design
Grids In Modern Web DesignKyle Meyer
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondDenise Jacobs
 
Designing CSS Layouts for the Flexible Web
Designing CSS Layouts for the Flexible WebDesigning CSS Layouts for the Flexible Web
Designing CSS Layouts for the Flexible WebZoe Gillenwater
 
Drupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid systemDrupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid systemFour Kitchens
 
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)Four Kitchens
 

Similar to Building Responsive Layouts with Fluid, Hybrid and Media Query Techniques (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
 
Ppt ch06
Ppt ch06Ppt ch06
Ppt ch06
 
Ppt ch06
Ppt ch06Ppt ch06
Ppt ch06
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
CSS Systems
CSS SystemsCSS Systems
CSS Systems
 
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...
 
What is grid system
What is grid systemWhat is grid system
What is grid system
 
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
 
Top 100 Diagrams in Editable Powerpoint
Top 100 Diagrams in Editable PowerpointTop 100 Diagrams in Editable Powerpoint
Top 100 Diagrams in Editable Powerpoint
 
Flexbox every developers dream
Flexbox every developers dreamFlexbox every developers dream
Flexbox every developers dream
 
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
Accelerated grid theming using NineSixty (DrupalCon San Francisco 2010)
 
Grid system introduction
Grid system introductionGrid system introduction
Grid system introduction
 
Grids In Modern Web Design
Grids In Modern Web DesignGrids In Modern Web Design
Grids In Modern Web Design
 
Layouts
Layouts Layouts
Layouts
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to Respond
 
Designing CSS Layouts for the Flexible Web
Designing CSS Layouts for the Flexible WebDesigning CSS Layouts for the Flexible Web
Designing CSS Layouts for the Flexible Web
 
Drupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid systemDrupal theming using the 960.gs grid system
Drupal theming using the 960.gs grid system
 
CSS
CSSCSS
CSS
 
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
Accelerated grid theming using NineSixty (Drupal Design Camp Boston 2010)
 

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 (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
 
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 (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
 
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
 
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
 
Designing with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & EfficientlyDesigning with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & EfficientlyZoe Gillenwater
 
Effective and Efficient Design with CSS3
Effective and Efficient Design with CSS3Effective and Efficient Design with CSS3
Effective and Efficient Design with CSS3Zoe Gillenwater
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSZoe 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 (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)
 
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 (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)
 
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
 
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
 
Web Accessibility
Web AccessibilityWeb Accessibility
Web Accessibility
 
Real-world CSS3
Real-world CSS3Real-world CSS3
Real-world CSS3
 
Designing with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & EfficientlyDesigning with CSS3 Effectively & Efficiently
Designing with CSS3 Effectively & Efficiently
 
Effective and Efficient Design with CSS3
Effective and Efficient Design with CSS3Effective and Efficient Design with CSS3
Effective and Efficient Design with CSS3
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSS
 

Recently uploaded

Case Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneCase Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneLukeKholes
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...SUHANI PANDEY
 
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Douxkojalkojal131
 
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️soniya singh
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...Call Girls in Nagpur High Profile
 
The Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticThe Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticTiaFebriani
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxTusharBahuguna2
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxjanettecruzeiro1
 
WAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsWAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsCharles Obaleagbon
 
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call GirlsCBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girlsmodelanjalisharma4
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...home
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentationamedia6
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...babafaisel
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵anilsa9823
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxmirandajeremy200221
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceanilsa9823
 
VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130
VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130
VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130Suhani Kapoor
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Case Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneCase Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, Pune
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
 
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
 
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
Call Girls in Kalkaji Delhi 8264348440 call girls ❤️
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
 
The Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aestheticThe Art of Batik, template ppt aesthetic
The Art of Batik, template ppt aesthetic
 
Design Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptxDesign Inspiration for College by Slidesgo.pptx
Design Inspiration for College by Slidesgo.pptx
 
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Brookefield Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptx
 
WAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past QuestionsWAEC Carpentry and Joinery Past Questions
WAEC Carpentry and Joinery Past Questions
 
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call GirlsCBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
CBD Belapur Individual Call Girls In 08976425520 Panvel Only Genuine Call Girls
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentation
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service  🧵
CALL ON ➥8923113531 🔝Call Girls Kalyanpur Lucknow best Female service 🧵
 
DragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptxDragonBall PowerPoint Template for demo.pptx
DragonBall PowerPoint Template for demo.pptx
 
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Aminabad Lucknow best Night Fun service
 
VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130
VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130
VIP Call Girls Service Kukatpally Hyderabad Call +91-8250192130
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 

Building Responsive Layouts with Fluid, Hybrid and Media Query Techniques

  • 1. Building Responsive Layouts by Zoe Mickley Gillenwater @zomigi August 28, 2012 Responsive Web Design Summit
  • 2. What I do Books Web Stunning CSS3: Accessibility A Project-based Guide to specialist at AT&T the Latest in CSS Visual designer www.stunningcss3.com CSS developer and consultant Flexible Web Design: Creating Liquid and Elastic Layouts with CSS www.flexiblewebbook.com 2
  • 3. why responsive web design works 3
  • 4.  what why responsive web design means 4
  • 5.  ? what why how to do responsive web design 5
  • 6. fluid/liquid layout uses percentage widths to adapt to size of viewport 6
  • 7. hybrid layout one+ column flexible, one+ not 7
  • 8. responsive web design fluid layout and flexible images adapted with media queries www.alistapart.com/articles/responsive-web-design/ 8
  • 9. adaptive layouts multiple fixed-width layouts swapped with media queries www.netmagazine.com/tutorials/adaptive-layouts-media-queries 9
  • 10. Look at this! This is so tough! I'm in such peril way up here! 10
  • 12. How do we make this fluid? 12
  • 13. Start with fluid wrapper 13
  • 14. Add opposing floats inside 14
  • 15. 3-column layout: nest 2-column layout inside 2-column 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 up to just under 100% • 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 fixed-width 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; } 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; } .row { margin-left: -10px; } 31
  • 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); } 32
  • 34. ? fluid hybrid main column fluid, sidebar fixed 34
  • 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 35
  • 37. Add wrapper with padding #content-wrapper { padding-right: 290px; } 37
  • 38. Lay out main content div #content-main { float: left; width: 100%; } 38
  • 39. Float sidebar #content-secondary { float: right; width: 250px; } 39
  • 40. A positive right margin 150px 40
  • 41. A negative right margin -150px 41
  • 42. Add negative right margin matching wrapper's right padding #content-secondary { float: right; width: 250px; margin-right: -290px; } 42
  • 43. Success! 43
  • 44. To make sidebar show in IE 6 #content-wrapper { zoom: 1; } #content-main, #content-secondary { display: inline; } 44
  • 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% 45
  • 46. ? fluid layout media queries feed different styles based on viewport size 46
  • 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 47
  • 49. Wide-screen media query /*all the other styles up here*/ @media screen and (min-width: 1200px) { /*styles for larger screens in here*/ } 49
  • 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%; } } 50
  • 51. Style nav as vertical menu @media screen and (min-width: 1200px) { ... #nav-main li { float: none; margin: 0; } #nav-main a { -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; } } 51
  • 53. Small-screen media query /*all the other styles up here*/ @media screen and (max-width: 760px) { /*styles for smaller screens in here*/ } 53
  • 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 54
  • 56. Mobile media query /*all the other styles up here*/ @media screen and (max-width: 550px) { /*styles for tiny screens in here*/ } 56
  • 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*/ } 57
  • 58. Changing to single column @media screen and (max-width: 550px) { #content-main, #content-secondary, #about, #credits { float: none; width: 100%; } } 58
  • 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); } } 59
  • 61. Viewport meta tag Forces mobile devices to scale viewport to actual device width <meta name="viewport" content="width=device-width"> 61
  • 62. Zoom problem in iOS • The device-width on iOS devices always matches portrait width • This means design doesn't reflow when you switch to landscape, but instead just zooms 62
  • 63. Fixing (and adding) zoom issues • Option 1: add maximum-scale=1 • But disables user scaling <meta name="viewport" content="width=device-width, maximum-scale=1"> • Option 2: add initial-scale=1 • Allows user scaling • But triggers over-zoom/crop bug when changing from portrait to landscape <meta name="viewport" content="width=device-width, initial-scale=1"> 63
  • 64. The best way to fix zoom issues • Option 3: add initial-scale=1 plus script to fix over-zoom bug • See http://filamentgroup.com/lab/a_fix_for_ the_ios_orientationchange_zoom_bug/ <head> ... <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="ios-orientationchange-fix.js"> ... </head> 64
  • 65. or conditional comments 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://zomigi.com/blog/responsive-layouts- presentation Zoe Mickley Gillenwater @zomigi design@zomigi.com zomigi.com | stunningcss3.com | flexiblewebbook.com Title photo by Steve James (http://www.flickr.com/photos/steeljam/3350481764/) Rock climbing photo by Justin Johnson (http://www.flickr.com/photos/justinjohnsen/4512815628/) 71