Skip to content

Instantly share code, notes, and snippets.

@ericf
Created May 8, 2011 22:12
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ericf/961730 to your computer and use it in GitHub Desktop.
Save ericf/961730 to your computer and use it in GitHub Desktop.
A simple, small, and powerful CSS Grid System (based on YUI 3 CSS Grids)
/* Based on YUI 3 CSS Grids: http://developer.yahoo.com/yui/3/cssgrids/ */
.layout {
letter-spacing: -0.31em; /* webkit: collapse white-space between units */
*letter-spacing: normal; /* reset IE < 8 */
word-spacing: -0.43em; /* IE < 8 && gecko: collapse white-space between units */
}
.layout > *,
.layout .unit {
display: inline-block;
zoom: 1; *display: inline; /* IE < 8: fake inline-block */
letter-spacing: normal;
word-spacing: normal;
vertical-align: top;
}
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<style>
/* Based on YUI 3 CSS Grids: http://developer.yahoo.com/yui/3/cssgrids/ */
.layout {
letter-spacing: -0.31em; /* webkit: collapse white-space between units */
*letter-spacing: normal; /* reset IE < 8 */
word-spacing: -0.43em; /* IE < 8 && gecko: collapse white-space between units */
}
.layout > *,
.layout .unit {
display: inline-block;
zoom: 1; *display: inline; /* IE < 8: fake inline-block */
letter-spacing: normal;
word-spacing: normal;
vertical-align: top;
}
#header, #footer { display: block; }
#content {
width: 70%;
direction: rtl;
}
#main, #nav { direction: ltr; }
#main { width: 75%; }
#nav { width: 25%; }
#sidebar { width: 30%; }
</style>
</head>
<body class="layout">
<div id="header">
<h1>Example</h1>
</div>
<div id="content">
<div class="layout">
<div id="main">
<h3>Main Content</h3>
</div>
<div id="nav">
<ul>
<li><a href="#main">Main</a></li>
<li><a href="#sidebar">Sidebar</a></li>
</ul>
</div>
</div>
</div>
<div id="sidebar">
<h3>Sidebar</h3>
<p>Sidebar’s content…</p>
</div>
<div id="footer">
<p>footer content…</p>
</div>
</body>
</html>
@ericf
Copy link
Author

ericf commented May 8, 2011

This is really just the core stuff in YUI 3 CSS Grids (the magic) stripped down to it's essential parts making it easy to pick up and use.

Here’s the example live: http://925html.com/files/grids/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment