41 | Try resizing your browser or viewing this page on different devices. Use the icon in the upper right corner to see an overlay of the grid.
42 |
43 |
44 |
45 |
46 |
47 |
48 |
A two-way split
49 |
50 | These two blocks of text will float side by side with some empty columns on the sides on large screens. On medium-sized screens the empty columns will disappear, and on small screens the blocks will be stacked vertically.
51 |
52 |
53 |
54 |
By the way
55 |
56 | If you're viewing this page on an iOS device, it might zoom in wonkily when you rotate your device. This is because of a Mobile Safari bug.
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/GGS.js:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Golden Gridlet (1.01)
4 | * by Joni Korpi
5 | * licensed under MIT
6 | *
7 | */
8 |
9 | var guideColor = 'rgb(255,195,0)';
10 | var guideInnerColor = 'rgba(255,255,255, 0.91)';
11 | var guideOpacity = '0.618';
12 |
13 | var switchColor = 'rgb(0,0,0)';
14 | var switchOpacity = '0.618';
15 |
16 | var baseFontSize = 16;
17 | var baselineGridHeight = (24 / baseFontSize)+'em';
18 |
19 | var eightColBreakpoint = ((720-1) / baseFontSize)+'em';
20 | var sixteenColBreakpoint = ((1872-1) / baseFontSize)+'em';
21 |
22 | /*
23 | * Note that the script might not work as expected if
24 | * the element of your page has a set width and
25 | * position: relative;, because the guides are appended
26 | * inside , but positioned in relation to .
27 | *
28 | * Also note that the baseline grid doesn't really align
29 | * up anymore after zooming the baseline grid in or out,
30 | * because of rounding errors.
31 | */
32 |
33 |
34 | /*!
35 | * Ender: open module JavaScript framework
36 | * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)
37 | * https://ender.no.de
38 | * License MIT
39 | * Build: ender -b jeesh
40 | */
41 | !function(a){function d(a,b){return c(a,b)}function c(a,e,f){d._select&&(typeof a=="string"||a.nodeName||a.length&&"item"in a||a==window)?(f=d._select(a,e),f.selector=a):f=isFinite(a.length)?a:[a];return b(f,c)}function b(a,b){for(var c in b)c!="noConflict"&&c!="_VERSION"&&(a[c]=b[c]);return a}b(d,{_VERSION:"0.2.4",ender:function(a,e){b(e?c:d,a)},fn:a.$&&a.$.fn||{}}),b(c,{forEach:function(a,b,c){for(c=0,l=this.length;c]+)/.exec(a),d=c.createElement(b&&k[b[1].toLowerCase()]||"div"),e=[];d.innerHTML=a;var f=d.childNodes;d=d.firstChild,e.push(d);while(d=d.nextSibling)d.nodeType==1&&e.push(d);return e}():z(a)?[a.cloneNode(!0)]:[]},J.doc=function(){var a=d.scrollWidth,b=d.scrollHeight,c=this.viewport();return{width:Math.max(a,c.width),height:Math.max(b,c.height)}},J.firstChild=function(a){for(var b=a.childNodes,c=0,d=b&&b.length||0,e;c=0;e=e-2)while(j=H[r[e+1]](j,c[f]))if(p=Q.apply(j,P(r[e])))break;p&&(d[g++]=c[f])}return d}function S(a,b,c){switch(a){case"=":return b==c;case"^=":return b.match(L.g("^="+c)||L.s("^="+c,new RegExp("^"+R(c))));case"$=":return b.match(L.g("$="+c)||L.s("$="+c,new RegExp(R(c)+"$")));case"*=":return b.match(L.g(c)||L.s(c,new RegExp(R(c))));case"~=":return b.match(L.g("~="+c)||L.s("~="+c,new RegExp("(?:^|\\s+)"+R(c)+"(?:\\s+|$)")));case"|=":return b.match(L.g("|="+c)||L.s("|="+c,new RegExp("^"+R(c)+"(-|$)")))}return 0}function R(a){return K.g(a)||K.s(a,a.replace(D,"\\$1"))}function Q(a,b,c,e,f,g,h){var j,k,l;if(b&&this.tagName.toLowerCase()!==b)return!1;if(c&&(j=c.match(u))&&j[1]!==this.id)return!1;if(c&&(q=c.match(v)))for(d=q.length;d--;){k=q[d].slice(1);if(!(J.g(k)||J.s(k,new RegExp("(^|\\s+)"+k+"(\\s+|$)"))).test(this.className))return!1}if(e&&!h){i=this.attributes;for(l in i)if(Object.prototype.hasOwnProperty.call(i,l)&&(i[l].name||l)==f)return this}if(e&&!S(g,this.getAttribute(f)||"",h))return!1;return this}function P(a){return a.match(G)}function O(a){while(a=a.previousSibling)if(a.nodeType==1)break;return a}function N(a){k=[];for(d=0,o=a.length;d])\s*/g,C=/([\s\>\+\~])(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\])/,D=/([.*+?\^=!:${}()|\[\]\/\\])/g,E=/^([a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,F=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,G=new RegExp(E.source+"("+F.source+")?"),H={" ":function(a){return a&&a!==A&&a.parentNode},">":function(a,b){return a&&a.parentNode==b.parentNode&&a.parentNode},"~":function(a){return a&&a.previousSibling},"+":function(a,b,c,d){if(!a)return!1;c=O(a),d=O(b);return c&&d&&c==d&&c}};I.prototype={g:function(a){return this.c[a]||undefined},s:function(a,b){this.c[a]=b;return b}};var J=new I,K=new I,L=new I,M=new I,Y="compareDocumentPosition"in A?function(a,b){return(b.compareDocumentPosition(a)&16)==16}:"contains"in A?function(a,c){c=c==b||c==window?A:c;return c!==a&&c.contains(a)}:function(a,b){while(a=a.parentNode)if(a===b)return 1;return 0},Z=b.querySelector&&b.querySelectorAll?function(a,c){if(b.getElementsByClassName&&(h=a.match(x)))return N(c.getElementsByClassName(h[1]));return N(c.querySelectorAll(a))}:function(a,c){a=a.replace(B,"$1");var d=[],f,i=[],j;if(h=a.match(z)){s=c.getElementsByTagName(h[1]||"*"),k=J.g(h[2])||J.s(h[2],new RegExp("(^|\\s+)"+h[2]+"(\\s+|$)"));for(j=0,g=s.length,e=0;j]+)/.exec(b)[1],f=(c||a).createElement(d[e]||"div"),g=[];f.innerHTML=b;var h=f.childNodes;f=f.firstChild,g.push(f);while(f=f.nextSibling)f.nodeType==1&&g.push(f);return g}var b=qwery.noConflict(),c="table",d={thead:c,tbody:c,tfoot:c,tr:"tbody",th:"tr",td:"tr",fieldset:"form",option:"select"};$._select=function(a,c){return/^\s* or ? */
48 | if (ender('body').offset().height > ender('html').offset().height) {
49 | var largerHeight = ender('body').offset().height;
50 | }
51 | else {
52 | var largerHeight = ender('html').offset().height;
53 | }
54 |
55 | /* Give guides the new height */
56 | ender('.ggs-guide').each(function() {
57 | ender(this).css('height', largerHeight);
58 | });
59 |
60 | /* Calculate the amount of lines needed and append them */
61 | var lines = Math.floor(largerHeight/24);
62 | ender('#ggs-baseline-container').empty();
63 | for (i=0; i<=lines; i++) {
64 | ender('#ggs-baseline-container').append('');
65 | }
66 |
67 | /* Set the baseline container to the same height as the guides, so there's no overflow */
68 | ender('#ggs-baseline-container').css('height', largerHeight);
69 | }
70 | }
71 |
72 | ender.domReady(function () {
73 |
74 | /* Add control classes and switch element */
75 | ender('body').addClass('ggs-hidden ggs-animated').append('
Golden Grid System (GGS) splits the screen into 18 even columns. The leftmost and rightmost columns are used as the outer margins of the grid, which leaves 16 columns for use in design.
78 |
79 |
Now, 16 columns sounds a bit much for anything other than huge widescreen monitors. This is where the folding, inspired by the DIN paper system and Unigrid, comes in. The 16 columns can be combined, or folded, into 8 columns for tablet-sized screens, and into 4 columns for mobile-sized ones. This way GGS can easily cover any screen sizes from 240 up to 2560 pixels.
80 |
81 |
The dimensions of the grid in each configuration are noted down within CSS comments, accompanied by suitable media queries, like thus:
While the column widths in GGS are proportional to the screen's width, the widths of its gutters (the spaces between columns) are proportional to the page's font-size, specified in ems.
105 |
106 |
Responsive grids that use gutters proportional to the screen can make the content feel like it's being squeezed together or pulled apart as the screen width changes. With elastic gutters this just doesn't happen, as the gutters always stay in proportion to the content.
107 |
108 |
Elastic gutters are created by positioning elements in the center of the gutter (using percentages) and giving them a padding equal to half of the gutter's width. For example:
Responsive layouts often require you to change the font-size at certain screen widths, for example to make the text easier to read on huge monitors, or to make the text fit better onto narrow mobile screens. This can make the proportions of your layout feel off, especially if you're using a baseline grid. GGS's zoomable baseline grid gets around this problem.
148 |
149 |
If you specify all your font-sizes, line-heights, as well as vertical paddings, margins and borders in ems, they'll all scale in proportion as the font-size is changed using media queries, always keeping the baseline grid intact (save for a 1px rounding error or two), which lets the layout keep the same vertical rhythm regardless of screen size.
150 |
151 |
GGS comes with a set of type presets aligned to a baseline grid, which is based on a base line-height of 1.5. Feel free to replace them with your own presets, though.
152 |
153 |
154 |
Golden Gridlet
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
Aligning elements in responsive layouts can be difficult with all the percentage values flying around. GGS comes with Golden Gridlet, a little script that adds a button into the upper right corner of the page. When clicked or tapped, it overlays the GGS grid and a baseline grid of 1.5em onto the page, making it easy to visually check that design elements align up.
167 |
168 |
Golden Gridlet should work in most modern browsers, and since it doesn't rely on a keyboard, it can be used on touch screen devices as well. In modern browsers, the overlay appears with a pleasing CSS3 transition. Give it a try by clicking or tapping the icon in the upper right corner of this page. It's pretty fun.
169 |
170 |
(Please note that due to rounding errors the baseline grid guides might not align up properly if the baseline grid is zoomed in or out.)
Both contain the source of GGS.css. GGS.less is written using the LESS CSS language. GGS.scss is written using the SCSS language, and was contributed by mikker.
Contains Golden Gridlet, a script that overlays the GGS grid and a baseline grid of 1.5em onto the page. Can be customized around the top of the file. Powered by the Ender library.
201 |
202 |
203 |
204 |
205 |
206 |
Many useful tips
207 |
And answers to some FAQs.
208 |
209 |
210 |
211 |
Don't use GGS as it is.
212 |
213 |
Take it apart, steal the parts that you like, and adapt them to your own way of working.
Or at least don't set one below 2560px. When your content starts getting too wide, use the zoomable baseline grid to make it fit a little better, or add some empty columns on the sides. The whole point of a fluid grid is to use the screen's proportions to align elements, so stick to it.
222 |
223 |
Mobile Safari causing trouble?
224 |
225 |
Does your site zoom in too much when changing orientations on an iOS device? It's because of this Mobile Safari bug.
226 |
227 |
228 |
229 |
230 |
GGS actually does very little.
231 |
232 |
It’s definitely not a framework. It’s more just a starting point and a couple of guidelines.
233 |
234 |
Serve IE6–8 just the mobile layout.
235 |
236 |
Old IE won't see any styles that are inside a media query, so just serve it your mobile layout and enhance it a little with IE-specific classes. Not having to worry about old IE makes coding the wider layouts so much easier. More about this in my blog post: Leaving Old Internet Explorer Behind.
237 |
238 |
Use box-sizing: border-box;
239 |
240 |
It lets you give the same element both a width in percentages as well as a padding in ems, which is required for the elastic gutters to work. If you followed my advice about IE6–8 above, you can use this inside media queries without worrying about browser support.
241 |
242 |
Don’t confuse GGS with "The Golden Grid".
243 |
244 |
The Golden Grid, made by @vladocar, is also a grid system. It has nothing to do with GGS. Accidental naming conflict. My fault.
245 |
246 |
247 |
248 |
249 |
250 |
251 |
289 |
290 |
303 |
304 |
305 |
306 |
--------------------------------------------------------------------------------
/license.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 Joni Korpi
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Golden Grid System
2 |
3 | A fluid-width grid system composed out of 18 even columns, two of which are used as outer margins, leaving 16 columns for use in design, which in turn can be combined into 8 columns or 4 columns as needed. They could also be doubled into 32 columns, but I don't think anyone needs a grid for 5000 CSS-px wide sites.
4 |
5 | See for more details.
6 |
7 | ## File list
8 |
9 | - **GGS.html** contains the required markup (namely the meta viewport tag) and a simple demo.
10 | - **GGS.css** contains the meat of GGS, with some demo code filled in. Details about its contents are scattered in CSS comments throughout the file.
11 | - **GGS.less** is the [LESS](http://lesscss.org/) source of GGS.css. It offers some customization for power users, and works as a nice starting point for LESS users.
12 | - **GGS.scss** is the same as GGS.less, but written in SCSS instead. Contributed by [mikker](https://github.com/mikker).
13 | - **GGS.js** contains Golden Gridlet, a script that overlays the GGS grid and a baseline grid of 1.5em onto the page. Can be customized around the top of the file. Powered by the [Ender library](http://ender.no.de/).
14 | - **goldengridsystem.com/** contains the source of the GGS site.
15 |
16 | ## Credits
17 |
18 | Developed by [Joni Korpi](http://jonikorpi.com/) / [@jonikorpi](http://twitter.com/jonikorpi/). Licensed under [MIT](http://opensource.org/licenses/mit-license.php).
19 |
--------------------------------------------------------------------------------