#grid v10
30 Nov 2015:#grid (or “Hashgrid”) is a little tool that inserts a layout grid in web pages, allows you to hold it in place, and toggle between displaying it in the foreground or background. To see it in action, hit g on your keyboard.
Download
Download #grid from GitHub
Features
- Adaptable for all layout widths and alignments
- Adaptable for any vertical rhythm value
- Set keyboard shortcuts to show and hide the grid, hold it in place, toggle it to the foreground and background, and jump between multiple grids
- Uses a single JavaScript file and a little CSS to control the grid lines, columns and gutters
#grid comes set up with a 980px-wide container that includes 20px gutters, and assumes one lead of 20px. A second 660px-wide container is included to show you how to set up multiple grids.
Installation
Copy the hashgrid.js script to your project
Add this script to your page(s) just before the closing
</body>
tagAdd the CSS to your page(s)
Modify #grid to suit your needs
The CSS and JavaScript is annotated to help you.
Usage
The document must have keyboard focus for #grid to work. You may need to click on the document background or TAB into the page first.
- g
- Show the grid until you release.
- g + h
- Show and hold the grid (g will remove it again).
- g + f
- Toggle the grid to the foreground and back. Pressing f while the grid is held also works.
- g + j
- Jump to the next grid. Pressing j while the grid is held also works.
Note: Hashgrid remembers the state of the grid when you refresh the page. While the grid is in front, you will not be able to interact with the page.
Release Notes
- v10 — 30 Nov 2015
- Works with vanilla JavaScript - jQuery is no longer required - thanks to widatama.
- v9 — 30 May 2013
- Minor release: Improved example usage to avoid conflicts.
- v8 — 6 Oct 2012
- Grid overlay can now be used inside a wrapping container with
position: relative;
rather than working inside the whole viewport. Thanks to Tom Arnold. - Holding down the #grid keys will no longer make browsers cry. Thanks to Callum Macrae.
- Fixes to cookie handling. Thanks to James Aitken.
- Optimisations.
- Grid overlay can now be used inside a wrapping container with
- v7 — 11 Jun 2011
- Minor release: Updated license references.
- v6 — 10 Jun 2011
- Minor release: Optimisations (thanks to Andrew Jaswa for contributions), and now released under an Apache License.
- v5 — 3 Nov 2010
- Vertical grid lines can now be set using CSS… images are no longer required! Thanks to Sean Coates for the contribution.
- Click events now interact with the page when the grid is in the foreground. Tested in WebKit and Gecko. Thanks to Phil Dokas for the tip about using the
pointer-events
CSS property. - Improved grid rendering, fixing a compatibility issue with jQuery 1.4.3. Thanks to everybody who’s given feedback.
- v4 — 29 Mar 2010
- Fixes for multiple grid support under WebKit (Safari and Chrome).
- v3 — 22 Feb 2010
- Multiple grids can be set up and cycled through at a key press. To avoid keyboard shortcut conflicts, the default keys have been changed (see Usage). Using CTRL, ALT or SHIFT as a modifier key is now optional. Keys no longer show or affect the grid while typing in forms.
- v2 — 2 Feb 2010
- Keys are now more easily configured (see top of hashgrid.js).
- Fixed crash when using with disabled CSS.
- Renamed the GridOverlay object to hashgrid.
- v1 — 21 Dec 2009
- First release.
Known Issues
- No known issues.
License
Copyright Jon Gibbins
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This essentially means that you’re free to copy, modify and distribute it for any project so long as you provide clear attribution to the author. Get in touch if you need a different license.