The Heads-Up Grid is an overlay grid for in-browser website development, built with HTML + CSS + JavaScript.
如果你还没有定义一个网格, 使用The Gridulator. 然后下载这个 The Heads-Up Grid 文件 并粘贴以下代码到你的网页的 <head> 元素:
<link href="headsupgrid/hugrid.css" type="text/css" rel="stylesheet" /> <script src="headsupgrid/jquery-1.6.2.min.js"></script> <script src="headsupgrid/hugrid.js"></script> <script type="text/javascript"> $(document).ready(function() { pageUnits = 'px'; colUnits = 'px'; pagewidth = 960; columns = 6; columnwidth = 140; gutterwidth = 24; pagetopmargin = 35; rowheight = 20; gridonload = 'off'; makehugrid(); setgridonload(); }); </script>
您可能注意到,通过查看默认的网格具有以下属性的文本:
改变数字来创建您所需的网格.如果你不需要基线网格,设置行高度为 0. 默认计量单位是 pixels.
你现在准备回到真正的工作:精心排列的图片和文字!
响应的网页设计, as described/defined by Ethan Marcotte anyway, is the act of creating various forms of the same basic site design that are optimized for different ranges of browser window widths.
Luckily, the way that I originally constructed the Heads-Up Grid made it relatively easy to adapt to the needs of responsive web design. You can quickly and easily define as many different grids as you need by way of basic JavaScript conditional statements. Even if you are not extremely comfortable with JavaScript, if you are ambitious enough to tackle responsive web design you will most likely have no problem figuring this out.
To create a responsive grid use the following code as a template. This template is fairly self-explanatory if you are familiar with CSS Media Queries. These JavaScript conditional properties should directly match the properties you are using for your media queries. Then simply define the properties of multiple grids in the same way you would define a single grid above.
The result should be a system that checks the browser window width on pageload as well as any time that the browser window is resized and render the appropriate grid.
<link href="headsupgrid/hugrid.css" type="text/css" rel="stylesheet" /> <script src="headsupgrid/jquery-1.6.2.min.js"></script> <script src="headsupgrid/hugrid.js"></script> <script type="text/javascript"> definegrid = function() { var browserWidth = $(window).width(); if (browserWidth >= 1001) { pageUnits = 'px'; colUnits = 'px'; pagewidth = 960; columns = 6; columnwidth = 140; gutterwidth = 24; pagetopmargin = 35; rowheight = 20; gridonload = 'off'; makehugrid(); } if (browserWidth <= 1000) { pageUnits = '%'; colUnits = '%'; pagewidth = 94; columns = 2; columnwidth = 48; gutterwidth = 4; pagetopmargin = 35; rowheight = 20; gridonload = 'off'; makehugrid(); } if (browserWidth <= 768) { pageUnits = '%'; colUnits = '%'; pagewidth = 96; columns = 2; columnwidth = 49; gutterwidth = 2; pagetopmargin = 35; rowheight = 20; gridonload = 'off'; makehugrid(); } } $(document).ready(function() { definegrid(); setgridonload(); }); $(window).resize(function() { definegrid(); setgridonresize(); }); </script>
Below is a complete list of properties available in the Heads-Up Grid system.
property name | values |
---|---|
pageUnits | px, % |
colUnits | px, % |
gridonload | on, off |
pagewidth | [number in pageUnits] |
columns | [number of columns] |
columnwidth | [number in colUnits] |
gutterwidth | [number in colUnits] |
pagetopmargin | [number in pixels] |
rowheight | [number in pixels] |
pageleftmargin | [number in pageUnits] |
pagerightmargin | [number in pageUnits] |
default value in bold
non-numerical property values must be defined within quotes: gridonload = 'off';
You can now contribute to this project by way of GitHub. I’m still learning about version control, but hopefully this will make it easier to improve and cotnribute to this project!
Nothing is ever finished. The Heads-Up Grid has been improved since its introduction. Below is a description of how it has been changed over time.