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

Building Hi-DPI (Retina) Responsive websites with Sass & Compass

Building Hi-DPI (Retina) Responsive websites with Sass & Compass

Using Sass & Compass to build Retina-enhanced, Responsive websites. An intro to the concept of Responsive design, and a brief intro to using the Susy Compass extension to build fluid Responsive layouts.

Nathan Henderson

April 20, 2013
Tweet

More Decks by Nathan Henderson

Other Decks in Design

Transcript

  1. Building Hi-DPI (Retina) Responsive websites with Sass & Compass Nathan

    Henderson – @nathos BarCamp Rochester Spring 2013 – 4/20/2013
  2. Why Repsonsive? ‣ Support for more devices & contexts ‣

    Requires designers think about content
  3. Media Queries .profile-pic { float: left; width: 250px; } @media

    screen and (max-width: 320px) { .profile-pic { width: 100px; float: none; } }
  4. Media Queries @media (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (-webkit-min-device-pixel-ratio: 1.5), (min-device-pixel-ratio:

    1.5), (min-resolution: 144dpi), (min-resolution: 1.5dppx) { /* your Retina styles */ } http://mir.aculo.us/2012/11/28/the-ultimate-target-retina-screens-media-query/
  5. Sass Media Queries .profile-pic { float: left; width: 250px; @media

    screen and (max-width: 320px) { width: 100px; float: none; } } http://vimeo.com/nathos/sass-and-compass
  6. Sass Media Queries .profile-pic { float: left; width: 250px; }

    @media screen and (max-width: 320px) { .profile-pic { width: 100px; float: none; } } .profile-pic { float: left; width: 250px; @media screen and (max-width: 320px) { width: 100px; float: none; } } “@media bubbling”
  7. .profile-pic { float: left; width: 250px; @media screen and (max-width:

    320px) { width: 100px; float: none; } } .profile-pic { width: 100px; @media (min-width: 620px) { width: 250px; float: left; } }
  8. Scale Down Images .container { /* Force images to scale

    down to their container widths. */ img max-width: 100%; height: auto; }
  9. Retina Images? ‣ Several options (server-side, JavaScript, media queries) ‣

    Consider using 2x resolution JPEGs at lower quality (higher compression) ‣ http://dh.karelia.com/retina/ ‣ Be careful, as this can result in very high res images; might hit mobile browser limits & use lots of RAM ‣ Do you need to retinafy content images at all?
  10. Sass Variables for Grid Constants // Define mobile-first grid constants.

    $total-columns : 4 // You can use ems, px or % to define the grid. $column-width : 60px $gutter-width : 20px $grid-padding : $gutter-width / 2
  11. Sass Variables for Breakpoints // Define breakpoints, in this case

    when there's room for the specified columns. $break-phone-landscape: 6 $break-tablet: 8 $break-desktop: 12 $break-huge: 16
  12. Semantic Grid Declarations @include at-breakpoint($break-tablet) .main-column, .sidebar @include span-columns(8, 8)

    @include at-breakpoint($break-desktop) .main-column @include span-columns(8, 12) .sidebar @include span-columns(4 omega, 12) @include at-breakpoint($break-huge) .main-column @include span-columns(10, 16) @include suffix(1) .sidebar @include span-columns(5 omega, 16)
  13. Other Tips ‣ Avoid images where possible ‣ Use CSS,

    Unicode characters, icon fonts, SVG ‣ Retinafy your favicon ‣ http://daringfireball.net/2013/01/retina_favicons ‣ http://www.xiconeditor.com