grid

960.gs grid overlay – a jQuery plugin

I’ve now released a bookmarklet to provide a simpler gird overlay.
Please also see grid960 – a grid overlay bookmarklet for 960.gs

I’ve been using 960.gs on a few sites recently. Without wanting to get into a discussion about the pros/cons of using css grid frameworks, I find them useful for some sites.

The 960.gs framework comes with a handy demo that shows a grid overlay, but the GIF images used have no transparency, so it is difficult to add a nice grid overlay to sites when developing them.

On the 960.gs home page there is a button by the thumbnail examples that dynamically adds a grid to the image. I Googled around for a similar solution, but didn’t find one that quite did what I wanted. So, I decided to build a simple jQuery plugin of my own.

Here’s a demo of the plugin in action.

To use the plugin, simply add the following code to your pages for a 12 column grid:


<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.960grid-1.0.min.js"></script>
<script type="text/javascript">
	$(function() {
		$("body").addGrid(12);
	});
</script>

thumbnail of 960grid plugin

Once the plugin is activated, a small toggle link will be visible in the top left-hand corner of the page. Unsurprisingly, if you change the input parameter from 12 to 16, you get a 16 column grid available!

The plugin relies on a couple of PNGs and by default the image path is set to /images/. You can override this setting, along with several others, by passing in some options as follows:


var options= {
	img_path: 'img/',
	z_index: 999,
	opacity:.6
};
$("body").addGrid(12, options);

As well as the image path, it is possible to override the default z-index used by the overlay, in case there is a conflict. You can also alter the opacity of the PNG if you require.

Please feel free to download the plugin for your own use. Let me know of any problems or suggested enhancements.