Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Responsive Design

Andy Hume
November 13, 2011

Responsive Design

Practical approaches to building responsive websites

Andy Hume

November 13, 2011
Tweet

More Decks by Andy Hume

Other Decks in Technology

Transcript

  1. From now on, instead of talking about making a site

    accessible, I'm going to talk about keeping it accessible. “ Jeremy Keith
  2. CORE.CSS STEPS[4] .product .title { font-size: 1em; } @media screen

    and (min-width: 60em) { .product .title { font-size: 1.4em; } } Keep modules together
  3. SELECTOR QUERIES? STEPS[4] <div class="product" data-squery="min-width: 400px=wide max-width:10em=small"> <p>Content here</p>

    </div> Adapt content based on container width https://github.com/ahume/selector-queries
  4. SELECTOR QUERIES? STEPS[4] .product img { max-width: 100%; } .product.wide

    img { // greater than 400px float: left; margin-right: 1em; max-width: auto; } Adapt content based on container width https://github.com/ahume/selector-queries
  5. IE <9 STEPS[5] Send full ‘desktop’ layout <link rel="stylesheet" href="core.css">

    <link rel="stylesheet" href="layout.css" media="screen and (min-width:40em)"> <!--[if lt IE 9]> <link rel="stylesheet" href="layout.css" media="screen"> <![endif]-->
  6. IE <9 STEPS[5] Send full ‘desktop’ layout - but not

    to mobile <link rel="stylesheet" href="core.css"> <link rel="stylesheet" href="layout.css" media="screen and (min-width:40em)"> <!--[if lt IE 9] & !(IEMobile)]> <link rel="stylesheet" href="layout.css" media="screen"> <![endif]-->
  7. IE <9 STEPS[5] Send full ‘desktop’ layout - or not

    <link rel="stylesheet" href="core.css"> <link rel="stylesheet" href="layout.css" media="screen and (min-width:40em)"> <!--[if lt IE 9] & !(IEMobile) & (gt IE6)]> <link rel="stylesheet" href="layout.css" media="screen"> <![endif]-->
  8. VIEWPORT STEPS[6] Set layout viewport width to the device width

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  9. RESPONSIVE IMAGES STEPS[7] Here and now? Image replacement <div class="logo">

    <img src="logo.png" alt="Company name"> </div> .logo { background-image: url(logo-large.png); } .logo img { position: absolute; left: -9999px; }
  10. ENHANCING CONTENT STEPS[9] if ($(document).width() > 640) { ! $.get('path/to/html',

    function(data) { ! ! $('[role="complementary"]').append(data); ! }); } What’s core content?