Griddlecake

A CSS Grid System That's Less Dumb

What Is Griddlecake?

Griddlecake is an attempt to come up with a solution to the limitations of standard 960 or 940 pixel CSS grids. While these grid systems are great and can be useful, their flexibility leaves something to be desired. Pages must be a certain width and they usually have mandatory padding or margin gutters on each side of a column. They also require extra classes and elements like clear:both elements or "first" and "last" classes for the corresponding columns.

How Is Griddlecake Better?

Griddlecake attempts to alleviate most of the inflexibility with many other CSS grids as well as simplifying them in a way that makes sense. The goals:

  1. Using percentage widths instead of fixed widths for column definitions
  2. Having no padding or margins defined in grid columns
  3. No extra clear elements needed

Here's an example of a simple page with two columns a left side menu and content on the right:

<div class="griddle">
        <div class="col25">
                <div class="space">
                        <!-- Sidebar -->
                </div>
        </div>
        <div class="col75">
                <div class="space">
                        <!-- Main Content -->
                </div>
        </div>
</div>

The .griddle class dictates the width of the page, which is set by you, the developer. The columns, in this case .col25 and .col75 have percentage-based widths that are (of course) determined by the width of their parent. The inner .space class (or the similar .bigspace class) is optional and provides padding for your content, but you can also make your own container classes and use them instead.

Download

Griddlecake is available in standard and compressed versions.

Standard (1.05KB) Compressed (748B)

Setup

Include griddlecake.css and add the following into your stylesheet (or inline if you prefer):

.griddle { width: 960px; }

Example Layouts

These are some basic layouts you could utilize with Griddlecake, if you desire:

Single Sidebar

Two Sidebars

Three Columns With Spacer

Three Even Columns

I'm A Pro, Sock It To Me

While Griddlecake allows you to layout a multi-column page with only two elements, thanks to the percentage-based widths, it is also capable of much more complex layouts. Here's a sample layout that's similar to the page you're looking at right now (with spacing elements removed for simplicity):

<div class="griddle">
        <div class="row">
                <!-- Website Header -->
        </div>
</div>
<div class="griddle">
        <div class="row">
                <div class="col65">
                        <!-- Main Content -->
                </div>
                <div class="col35">
                        <!-- Sidebar Content -->
                </div>
        </div>
</div>
<div class="griddle">
        <div class="row">
                <!-- Bottom Content -->
        </div>
</div>

Nesting the menu and main content columns inside a 100% width column (class row or col100, if you prefer) is not necessary, however it allows you to set a background color to whichever column you know will always be shorter, in this case that of the right column with the example layouts.

Responsive-Ready

The other advantage is that (depending on the design) pages can be scaled to different widths very easily without needing to clutter up your media queries. This will aid in responsive designs as well as allow you to scale your page (to add another column, perhaps) as you see fit. Check out what happens when the container width changes:

Griddlecake eXtreme

Still not satisfied? Is 20 columns not enough to satiate your hunger for grid-based CSS layouts? Griddlecake eXtreme is for you, then! Probably! The eXtreme version is 100 columns, each 1% width. Why would you want to use this? I have no idea! Maybe you want to have a column that's 73%? Do whatever you want!

Griddlecake eXtreme is available in standard and minified versions:

Standard (3.73KB) Minified (3.00KB)

About Griddlecake

Griddlecake™ (oh yeah!) was created by Mike Watson, who thinks CSS is pretty sweet. The name 'Griddlecake' is partially a (weak) pun (because it has the word 'grid' in it, get it) but mostly named after his dog, Pancake. Griddlecake is released under the Creative Commons Attribution 3.0 Unported License. The current version is version 1.0.