├── README ├── css ├── example │ ├── global.css │ └── layout.css ├── global.css └── layout.css ├── example.html ├── images └── example │ ├── footer-logo.png │ ├── header-logo.png │ ├── responsive.jpg │ ├── responsive2.jpg │ ├── responsive3.jpg │ └── responsive4.jpg ├── index.html └── js └── libs └── modernizr-1.7.min.js /README: -------------------------------------------------------------------------------- 1 | Goldilocks Approach 2 | =================== 3 | 4 | A good starting point for responsive web design that takes device resolution out of the equation 5 | 6 | How does it work? 7 | ----------------- 8 | 9 | The Goldilocks Approach uses a combination of Ems, Max-Width, Media Queries and Pattern Translations to consider just three states that allow your designs to be resolution independent. Check out the example.html page included to see how it works. 10 | 11 | It contains 12 | ----------- 13 | 14 | * 2 well commented CSS files that consider 3 CSS Media Query increments; multi column, narrow column and single column 15 | * Good typographic defaults out of the box (including print contexts) 16 | * A boilerplate HTML file to get you started (index.html) 17 | -------------------------------------------------------------------------------- /css/example/global.css: -------------------------------------------------------------------------------- 1 | @import url("../global.css"); 2 | 3 | /* 4 | This file contains the unique styles needed for example.html which do not appear in /css/global.css 5 | ---------------------------------------------------------------------------------------- 6 | */ 7 | 8 | html { 9 | background: rgb(244, 244, 244); 10 | } 11 | 12 | /* 5. GLOBAL LAYOUT & GLOBAL CUSTOM TYPOGRAPHY 13 | ----------------------------------------------------------------------------------------*/ 14 | h1 { 15 | text-align: center; 16 | font-size: 2.618em; 17 | line-height: 1.2em; 18 | } 19 | 20 | h3 { text-transform:uppercase; letter-spacing:0.12em; } 21 | h3, h4, h5, h6 { font-weight: bold; } 22 | 23 | p.intro { font-size: 1.309em; margin-bottom: 1em; } 24 | 25 | header { text-align:center; } 26 | 27 | footer { 28 | margin:1.618em 0 0; 29 | padding: 1.618em 0 0; 30 | border-top: 1px solid rgb(102,102,102); 31 | border-bottom: 1px solid rgb(102,102,102); 32 | } 33 | 34 | footer p { float: left; margin-right:1em; } 35 | 36 | 37 | /* 6. CUSTOM LAYOUT & TYPOGRAPHY (Baby bear) 38 | ----------------------------------------------------------------------------------------*/ 39 | 40 | header img#header-logo { margin-bottom:-0.809em; } 41 | 42 | header h2:before { 43 | content:""; 44 | border-bottom:1px solid #333; 45 | height: 1.618em; 46 | width: 35%; 47 | display: block; 48 | float: left; 49 | } 50 | 51 | header h2:after { 52 | content:""; 53 | border-bottom:1px solid #333; 54 | height: 1.618em; 55 | width: 35%; 56 | display: block; 57 | float: right; 58 | } -------------------------------------------------------------------------------- /css/example/layout.css: -------------------------------------------------------------------------------- 1 | /* 8. CUSTOM LAYOUT & TYPOGRAPHY (Daddy bear) 2 | ----------------------------------------------------------------------------------------*/ 3 | #container { 4 | padding: 1.618em; 5 | margin: 0 auto; 6 | max-width: 60em; 7 | } 8 | 9 | header h2:before, header h2:after { width: 42%; } 10 | 11 | h1 { font-size: 4.4em; line-height:1.618em; margin-bottom:0.1em; } 12 | 13 | h1 span { 14 | font-family: "proxima-nova-1","proxima-nova-2", arial, helvetica, sans-serif; 15 | text-transform: uppercase; 16 | letter-spacing:0.1em; 17 | font-size:0.382em; 18 | line-height:3.236em; 19 | display:block; 20 | } 21 | 22 | h1 span:before, h1 span:after { 23 | content:""; 24 | border-top:1px solid #333; 25 | height: 0.1em; 26 | width: 19%; 27 | display: block; 28 | margin-top: 1.618em; 29 | } 30 | 31 | h1 span:before { float: left; } 32 | h1 span:after { float: right; } 33 | 34 | ul { margin-left: 0.4em; } 35 | ol { margin-left: 0.4em; } 36 | 37 | p.intro { 38 | font-size: 1.618em; 39 | line-height:1.4289em; 40 | max-width: 20em; 41 | margin-bottom: 1em; 42 | } 43 | 44 | aside { 45 | float: right; 46 | clear: right; 47 | width: 25em; 48 | margin-top:-12.5em; 49 | height:auto; 50 | } 51 | 52 | footer p { max-width: 17.942em; } 53 | 54 | 55 | /* 9. CUSTOM LAYOUT & TYPOGRAPHY (Mummy bear) 56 | ----------------------------------------------------------------------------------------*/ 57 | @media screen and (min-width: 30em) and (max-width: 63.236em) { 58 | 59 | #container { width: 30em; } 60 | 61 | header h2:before, header h2:after { width: 35%; } 62 | 63 | h1 { font-size: 2.618em; line-height: 1.4em; } 64 | h1 span { font-size:0.5em; } 65 | h1 span:before, h1 span:after { width: 10%; } 66 | 67 | p.intro { 68 | font-size: 1.309em; 69 | margin-bottom: 1em; 70 | max-width: 33em; 71 | } 72 | 73 | aside { 74 | float: none; 75 | width: auto; 76 | height: auto; 77 | margin: 0 0 2.2em; 78 | } 79 | 80 | } -------------------------------------------------------------------------------- /css/global.css: -------------------------------------------------------------------------------- 1 | /* 2 | Goldilocks Approach to Responsive Web Design Boilerplate 3 | 4 | Author: Design by Front - @designbyfront 5 | Version: 0.1 6 | URL: http://www.goldilocksapproach.com 7 | ---------------------------------------------------------------------------------------- 8 | 9 | CONTENTS - GLOBAL.CSS 10 | ----------------------------------------- 11 | 1. RESET 12 | 2. ROOT 13 | 3. CORE TYPOGRAPHY 14 | 4. LINKS 15 | 5. GLOBAL LAYOUT & GLOBAL CUSTOM TYPOGRAPHY 16 | 6. CUSTOM LAYOUT & TYPOGRAPHY (Baby bear) 17 | 7. BROWSER AND NON-SEMANTIC STYLING 18 | 19 | CONTENTS - LAYOUT.CSS 20 | ----------------------------------------- 21 | 8. CUSTOM LAYOUT & TYPOGRAPHY (Daddy bear) 22 | 9. CUSTOM LAYOUT & TYPOGRAPHY (Mummy bear) 23 | 24 | */ 25 | 26 | 27 | /* 1. RESET 28 | ----------------------------------------------------------------------------------------*/ 29 | html, body, div, span, applet, object, iframe, 30 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 31 | a, abbr, acronym, address, big, cite, code, 32 | del, dfn, em, ins, kbd, q, s, samp, 33 | small, strike, strong, sub, sup, tt, var, 34 | b, u, i, center, 35 | dl, dt, dd, ol, ul, li, 36 | fieldset, form, label, legend, 37 | table, caption, tbody, tfoot, thead, tr, th, td, 38 | article, aside, canvas, details, embed, 39 | figure, figcaption, footer, hgroup, 40 | menu, nav, output, ruby, section, summary, 41 | time, mark, audio, video { 42 | margin: 0; 43 | padding: 0; 44 | border: 0; 45 | font-size:100%; 46 | font: inherit; 47 | vertical-align: baseline; 48 | } 49 | 50 | article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { 51 | display: block; 52 | } 53 | 54 | 55 | /* 2. ROOT 56 | ----------------------------------------------------------------------------------------*/ 57 | html { 58 | overflow-y: scroll; 59 | background: #FFF; 60 | } 61 | 62 | /* /ht Ethan Marcotte - http://front.ie/l8rJaA */ 63 | img, embed, object, video { max-width: 100%; } 64 | .ie6 img.full, .ie6 object.full, .ie6 embed, .ie6 video { width: 100%; } 65 | 66 | 67 | /* 3. CORE TYPOGRAPHY 68 | ----------------------------------------------------------------------------------------*/ 69 | body { 70 | font-family: Georgia, "Times New Roman", serif; 71 | font-size: 1em; 72 | line-height: 1.618em; 73 | color: #333; 74 | } 75 | 76 | h1, h2, h3, h4, h5, h6 { 77 | margin-bottom: 0.809em; 78 | line-height: 1em; 79 | } 80 | 81 | p, ul, ol, dl, blockquote { 82 | font-size: 1em; 83 | line-height: 1.618em; 84 | margin-bottom: 1.618em; 85 | max-width: 30em; /* Optimal width for long-form text */ 86 | } 87 | 88 | ul { list-style-type: disc; margin-left: 1.618em; } 89 | ol { list-style-type: decimal; margin-left: 1.618em; } 90 | nav ul, nav ol { list-style: none; margin: 0; padding: 0;} 91 | 92 | b, strong { font-weight: bold; } 93 | i, em { font-style: italic; } 94 | small { font-size: 80%; } 95 | 96 | 97 | /* 4. LINKS 98 | ----------------------------------------------------------------------------------------*/ 99 | a, a:visited { outline: none; color: #439BBD; text-decoration: underline; } 100 | a:hover { outline: none; text-decoration:none; } 101 | a:active, a:focus { outline: none; } 102 | 103 | 104 | /* 5. GLOBAL LAYOUT & GLOBAL CUSTOM TYPOGRAPHY 105 | ----------------------------------------------------------------------------------------*/ 106 | 107 | 108 | 109 | /* 6. CUSTOM LAYOUT & TYPOGRAPHY (Baby bear) 110 | ----------------------------------------------------------------------------------------*/ 111 | #container { 112 | padding: 0.809em; 113 | max-width: 30em; 114 | margin: auto; 115 | } 116 | 117 | aside { width: 100%; } 118 | 119 | 120 | /* 7. BROWSER AND NON-SEMANTIC STYLING 121 | ----------------------------------------------------------------------------------------*/ 122 | .cf:before, .cf:after { content: ""; display: block; } 123 | .cf:after { clear: both; } 124 | .ie6 .cf { zoom: 1 } -------------------------------------------------------------------------------- /css/layout.css: -------------------------------------------------------------------------------- 1 | /* 8. CUSTOM LAYOUT & TYPOGRAPHY (Daddy bear) 2 | ----------------------------------------------------------------------------------------*/ 3 | #container { 4 | padding: 1.618em; 5 | margin: 0 auto; 6 | max-width: 60em; 7 | } 8 | 9 | 10 | /* 9. CUSTOM LAYOUT & TYPOGRAPHY (Mummy bear) 11 | ----------------------------------------------------------------------------------------*/ 12 | @media screen and (min-width: 30em) and (max-width: 63.236em) { 13 | 14 | #container { width: 30em; } 15 | 16 | } -------------------------------------------------------------------------------- /example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 | 38 |
39 |
40 |

41 | 42 |

43 |

The Goldilocks Approach to Responsive Web Design

44 |
45 | 46 |
47 |

With over 4 billion mobile devices in use around the world, mobile browsing is rising fast. We can no longer assume that our sites will be viewed on a desktop monitor with an average resolution. Perhaps we never could.

48 | 49 | 52 | 53 |

The answer, proposed by Ethan Marcotte, is Responsive Web Design. Instead of building separate sites for each device, we build one site that adapts to each device. However, the current approach to responsive design is still based on a few popular devices and, as a result, is likely to become obsolete as fast as they do.

54 |

What if we could create a truly universal design that was device independent – one that, no matter what device you viewed it on, looked like it was designed just for that device? At New Adventures, Mark Boulton talked about designing from the content out, rather than the canvas in, and we think this makes good sense. Perhaps the only way to create a design that will work on any device is to forget about the device altogether.

55 | 56 |

Current Practice

57 |

The current approach to responsive design binds the design to the device. It uses pixel widths based on the dimensions of the most common devices, but we don’t think this approach is good enough. It results in designs that are based on two big inconstants:

58 | 59 |
    60 |
  • device resolution; and,
  • 61 |
  • pixels.
  • 62 |
63 | 64 |

Device resolution

65 |

There are thousands of different devices out there, with millions of potential contexts. We can’t support them all, so we end up choosing a few popular devices, basing our designs on their resolutions, and ignoring the rest of the products on the market. When technology moves on and resolutions increase, our sites will look as outdated as a 600×400 site does now.

66 | 67 |

Pixels

68 |

Pixels sizes aren’t constant – or at least the display of them isn’t. 16px text on an iPhone can be ~60% the size of 16px text on a Macbook. Basing designs on pixel measurements creates inconsistency in viewing size across devices and can negatively affect readability and usability.

69 | 70 |

The Device Doesn’t Matter

71 |

So how do we do as Mark Boulton suggests and go about designing from the content out? In practice, it means starting with the most common form of content, the paragraph element, and building up to a full layout.

72 |

It’s tempting to first set the body font size. But the manufacturer or the user has already set the browser’s default size for readability, and we don’t think you should mess with it without good reason.

73 |

However, if you base your entire design on this base font size (using ems), then as it increases or decreases, so will your design. Using ems allows your designs to be resolution independent.

74 |

75 |

Next, use max-width to set the line length of the paragraph to be as readable as possible (~66 characters per line). This will vary from font to font, but something around 30em usually does the trick. This sets the width of your single column layout, making it ‘just right’ for readability.

76 | 77 |

The Goldilocks Approach

78 |

Now, no matter which device your design is viewed in, the space available will be bigger, smaller, or just right, and you can use media queries to make the most of it.

79 | 80 |

81 | 82 |

Too big

83 |

If there is substantially more space than the single column width, then you can consider moving to a multi-column layout. For example, if the single column width is 28em (plus 1em margin on either side), and the screen width is more than 45em, then you have enough room to move to a three-column layout with 13.5em columns and 1em gutters, with the main content spanning two columns (so remaining the optimum width for readability).

84 |

85 | 86 |

Too small

87 |

If there’s less space than what’s required for optimum readability, then you need to make the most of the space you have. For example:

88 | 89 |
    90 |
  • halving the outer margin (but not removing it); and/or
  • 91 |
  • bringing any hanging punctuation inline (so it isn’t cut off).
  • 92 |
93 | 94 |

95 | 96 |

Just right

97 |

If the space available is just right for your single column, then you’ve nothing to worry about. Your work here is done. Go make a cup of tea.

98 |

We’re not saying that a single column layout is the best layout for every site. We don’t know which layout a user will be viewing, so our sites need to work just as well in a single column state as they do with multiple columns. However, in practice, we’ve found that it helps to get the single column state right and then work up or down.

99 | 100 |

The Perks

101 |

We think this approach has a quite a few benefits.

102 |

With the current approach, even if you only designed for Apple devices (lucky!), you would require up to five different states:

103 | 104 |
    105 |
  1. iMac (large display)
  2. 106 |
  3. Macbook (smaller display)
  4. 107 |
  5. iPad (tablet – could be portrait or landscape)
  6. 108 |
  7. iPhone 4 (Retina)
  8. 109 |
  9. iPhone (non-retina).
  10. 110 |
111 | 112 |

The Edenspiekermann site seems to take this approach and does it very well, but it’s just not a scalable solution. With the Goldilocks approach, you only have to consider three states:

113 | 114 |
    115 |
  1. multi column (too big)
  2. 116 |
  3. narrow column (too small)
  4. 117 |
  5. single column (just right).
  6. 118 |
119 | 120 |

By taking the device resolution out of the equation, you get layouts that should work across all devices and contexts, even ones that haven’t been invented yet. If, for whatever reason, a user has their base font size set to 80px, then this approach should still produce an appropriate layout for the space available. Talk about device independence.

121 |

And finally, technology changes, but the human body has stayed pretty constant for the past few thousand years. By designing for human constraints (readability) rather than technological constraints (device size and resolution), your layouts won’t date any time soon.

122 |

And so the designers lived happily ever after…

123 |

Responsive design requires a new way of thinking, and there’s still plenty of discussion and exploration to be had before we can settle on what is ‘best practice’. We’ve found this approach to work well for us, but how do you think it would work for you?

124 | 125 |

« Read the original article

126 | 127 |
128 |

129 |

Front is an award-winning web strategy and design studio committed to making the web a better place.

130 |
131 | 132 |
133 | 134 |
135 | 136 |
137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /images/example/footer-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/designbyfront/The-Goldilocks-Approach/1b0afd264cbbd16dc9c2baea1e91d5eee2ec9971/images/example/footer-logo.png -------------------------------------------------------------------------------- /images/example/header-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/designbyfront/The-Goldilocks-Approach/1b0afd264cbbd16dc9c2baea1e91d5eee2ec9971/images/example/header-logo.png -------------------------------------------------------------------------------- /images/example/responsive.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/designbyfront/The-Goldilocks-Approach/1b0afd264cbbd16dc9c2baea1e91d5eee2ec9971/images/example/responsive.jpg -------------------------------------------------------------------------------- /images/example/responsive2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/designbyfront/The-Goldilocks-Approach/1b0afd264cbbd16dc9c2baea1e91d5eee2ec9971/images/example/responsive2.jpg -------------------------------------------------------------------------------- /images/example/responsive3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/designbyfront/The-Goldilocks-Approach/1b0afd264cbbd16dc9c2baea1e91d5eee2ec9971/images/example/responsive3.jpg -------------------------------------------------------------------------------- /images/example/responsive4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/designbyfront/The-Goldilocks-Approach/1b0afd264cbbd16dc9c2baea1e91d5eee2ec9971/images/example/responsive4.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 | 38 |
39 | 40 |
41 | 42 | 43 | 44 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /js/libs/modernizr-1.7.min.js: -------------------------------------------------------------------------------- 1 | // Modernizr v1.7 www.modernizr.com 2 | window.Modernizr=function(a,b,c){function G(){e.input=function(a){for(var b=0,c=a.length;b7)},r.history=function(){return !!(a.history&&history.pushState)},r.draganddrop=function(){return x("dragstart")&&x("drop")},r.websockets=function(){return"WebSocket"in a},r.rgba=function(){A("background-color:rgba(150,255,150,.5)");return D(k.backgroundColor,"rgba")},r.hsla=function(){A("background-color:hsla(120,40%,100%,.5)");return D(k.backgroundColor,"rgba")||D(k.backgroundColor,"hsla")},r.multiplebgs=function(){A("background:url(//:),url(//:),red url(//:)");return(new RegExp("(url\\s*\\(.*?){3}")).test(k.background)},r.backgroundsize=function(){return F("backgroundSize")},r.borderimage=function(){return F("borderImage")},r.borderradius=function(){return F("borderRadius","",function(a){return D(a,"orderRadius")})},r.boxshadow=function(){return F("boxShadow")},r.textshadow=function(){return b.createElement("div").style.textShadow===""},r.opacity=function(){B("opacity:.55");return/^0.55$/.test(k.opacity)},r.cssanimations=function(){return F("animationName")},r.csscolumns=function(){return F("columnCount")},r.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";A((a+o.join(b+a)+o.join(c+a)).slice(0,-a.length));return D(k.backgroundImage,"gradient")},r.cssreflections=function(){return F("boxReflect")},r.csstransforms=function(){return!!E(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])},r.csstransforms3d=function(){var a=!!E(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);a&&"webkitPerspective"in g.style&&(a=w("@media ("+o.join("transform-3d),(")+"modernizr)"));return a},r.csstransitions=function(){return F("transitionProperty")},r.fontface=function(){var a,c,d=h||g,e=b.createElement("style"),f=b.implementation||{hasFeature:function(){return!1}};e.type="text/css",d.insertBefore(e,d.firstChild),a=e.sheet||e.styleSheet;var i=f.hasFeature("CSS2","")?function(b){if(!a||!b)return!1;var c=!1;try{a.insertRule(b,0),c=/src/i.test(a.cssRules[0].cssText),a.deleteRule(a.cssRules.length-1)}catch(d){}return c}:function(b){if(!a||!b)return!1;a.cssText=b;return a.cssText.length!==0&&/src/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(b.split(" ")[0])===0};c=i('@font-face { font-family: "font"; src: url(data:,); }'),d.removeChild(e);return c},r.video=function(){var a=b.createElement("video"),c=!!a.canPlayType;if(c){c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"');var d='video/mp4; codecs="avc1.42E01E';c.h264=a.canPlayType(d+'"')||a.canPlayType(d+', mp4a.40.2"'),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return c},r.audio=function(){var a=b.createElement("audio"),c=!!a.canPlayType;c&&(c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"'),c.mp3=a.canPlayType("audio/mpeg;"),c.wav=a.canPlayType('audio/wav; codecs="1"'),c.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;"));return c},r.localstorage=function(){try{return!!localStorage.getItem}catch(a){return!1}},r.sessionstorage=function(){try{return!!sessionStorage.getItem}catch(a){return!1}},r.webWorkers=function(){return!!a.Worker},r.applicationcache=function(){return!!a.applicationCache},r.svg=function(){return!!b.createElementNS&&!!b.createElementNS(q.svg,"svg").createSVGRect},r.inlinesvg=function(){var a=b.createElement("div");a.innerHTML="";return(a.firstChild&&a.firstChild.namespaceURI)==q.svg},r.smil=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"animate")))},r.svgclippaths=function(){return!!b.createElementNS&&/SVG/.test(n.call(b.createElementNS(q.svg,"clipPath")))};for(var H in r)z(r,H)&&(v=H.toLowerCase(),e[v]=r[H](),u.push((e[v]?"":"no-")+v));e.input||G(),e.crosswindowmessaging=e.postmessage,e.historymanagement=e.history,e.addTest=function(a,b){a=a.toLowerCase();if(!e[a]){b=!!b(),g.className+=" "+(b?"":"no-")+a,e[a]=b;return e}},A(""),j=l=null,f&&a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="";return a.childNodes.length!==1}()&&function(a,b){function p(a,b){var c=-1,d=a.length,e,f=[];while(++c