-
Notifications
You must be signed in to change notification settings - Fork 7
Arrange
Arrange is a very simple, flexible grid framework for quick-building, prototyping, or production-level code. Its goal is to help you by doing as little as possible while staying out of your way.
- Getting Started
- Basic Usage
- Class Aliases
- Nesting Grids
- Offsets
- Responsiveness
- Reverse Order
- Off-Grid Equal-Width Columns
- Collapsed Grids
- Reducing File Size
- Oh, Safari
- Change Log
The first step to getting started with using Arrange is to include the CSS file on your page. You can do this with a call that looks like so:
<link href="/path/to/arrange.css" rel="stylesheet">Note: you'll want to change the path of your
hrefattribute to point to the actual file, wherever it's located on your server.
That's it, you should be good to go. Arrange doesn't have any JavaScript components to make it work, everything is contained in that one CSS file.
In its most basic for, Arrange will work something like this:
<div class="row">
<div class="four columns">
<!-- this would be a 1/3-width column -->
</div>
<div class="eight columns">
<!-- this would be a 2/3-width column -->
</div>
</div>What's happening here:
- An element with the class
rowwraps the columns you wish to set up, this element is responsible for clearing your columns (which are floated) so that as content in the columns expand, the row expands with it - Child elements with the class
columnsand the number of columns to span are included within, each column element is being floated left
The important thing to note is that the number of columns used add up to twelve.
There are a couple of aliases in place to let you use the words that make sense to you.
- You can use the class
roworcontainerfor the element holding columns - You can use the class
columnsorcolumnfor the elements that are spanning columns - Rather than specifying the number of columns to span, you can also use the width that you're trying to accomplish with the following helpers:
-
onecan betwelfthorone-twelfth -
twocan besixthorone-sixth -
threecan bequarterorfourthorone-quarterorone-fourth -
fourcan bethirdorone-third -
sixcan behalforone-half -
eightcan betwo-thirds -
ninecan bethree-quartersorthree-fourths -
twelvecan befull
-
These classes have been included to work with the different ways that you might think about column widths. If you choose to use the fraction-based names, instead of columns adding up to twelve, they should total to one.
Grids can be nested. That might look something like this:
<div class="row">
<div class="four columns">
<!-- this would be a 1/3-width column -->
</div>
<div class="eight columns row">
<!-- this would be a 2/3-width column that can hold its own columns -->
<div class="six columns">
<!-- this would be 1/2-width of the 2/3-width column -->
</div>
<div class="six columns">
<!-- this would also be 1/2-width of the 2/3-width column -->
</div>
</div>
</div>Note: the column in the first set of columns that will be holding sub-columns also has a the
rowclass applied to it. This will enable that column to expand to the sub-columns that it holds.
If you want to leave some white space between columns, you'll use the offset classes. These use the same set of numbers and number-aliases above, but are prepended by offset-by-. For example, let's say you wanted to have two columns, but leave a little room between them, you might do something like this:
<div class="row">
<div class="six columns">
<!-- this would be a 1/2-width column -->
</div>
<div class="five columns offset-by-one">
<!-- this would be a 5/12-width column pushed over a 1/12-width column -->
</div>
</div>This is a full row (because six plus five plus the offset-by-one makes twelve).
Arrange doesn't try to handle responsiveness out-of-the-box; it only handles laying out columns into a flexible grid. That is by design. Grid columns can be made responsive through media queries, but that all must be done manually, as it isn't something that can be properly guessed out-of-the-box.
Use break points that make sense to your project and adjust from there.
Sometimes for responsiveness you don't want your left columns coming before your right columns. This is where reverse comes in. By specifying this class on your row element, columns within will float right instead of left, reversing the order that they show up on the page.
This would work like this:
<div class="reverse row">
<div class="four columns">
<!-- this would be a 1/3-width column -->
</div>
<div class="eight columns">
<!-- this would be a 2/3-width column -->
</div>
</div>Note: in the CSS file itself, the reverse classes are the second section of
arrange.css. If you aren't going to use the reverse classes, it is recommended this section from the file to save on file-size.
Sometimes you'll need to break out of the twelve-column system, and Arrange gives you the tools to do so. Included with the standard columns are the following off-grid systems, each with their own class aliases for determining column widths:
- One-fifth columns, with the following available classes:
-
one-fifthorfifthfor column width,offset-by-one-fifthoroffset-by-fifthfor offset -
two-fifthsfor column width,offset-by-two-fifthsfor offset -
three-fifthsfor column width,offset-by-three-fifthsfor offset -
four-fifthsfor column width,offset-by-four-fifthsfor offset
-
- One-seventh columns, with the following available classes:
-
one-seventhorseventhfor column width,offset-by-one-seventhoroffset-by-seventhfor offset -
two-seventhsfor column width,offset-by-two-seventhsfor offset -
three-seventhsfor column width,offset-by-three-seventhsfor offset -
four-seventhsfor column width,offset-by-four-seventhsfor offset -
five-seventhsfor column width,offset-by-five-seventhsfor offset -
six-seventhsfor column width,offset-by-six-seventhsfor offset
-
- One-eighth columns (which can be used in conjunction with
one-fourthandhalfcolumns)-
one-eighthoreighthfor column width,offset-by-one-eighthoroffset-by-eighthfor offset -
three-eighthsfor column width,offset-by-three-eighthsfor offset -
five-eighthsfor column width,offset-by-five-eighthsfor offset -
seven-eighthsfor column width,offset-by-seven-eighthsfor offset
-
- One-ninth columns (which can be used in conjunction with
one-thirdandtwo-thirdscolumns)-
one-ninthorninthfor column width,offset-by-one-ninthoroffset-by-ninthfor offset -
two-ninthsfor column width,offset-by-two-ninthsfor offset -
four-ninthsfor column width,offset-by-four-ninthsfor offset -
five-ninthsfor column width,offset-by-five-ninthsfor offset -
seven-ninthsfor column width,offset-by-seven-ninthsfor offset -
eight-ninthsfor column width,offset-by-eight-ninthsfor offset
-
- In the CSS file itself, the these classes are grouped together into a perforated section; if you aren't going to use these classes, it is recommended this section from the file to save on file-size
- Each of these sets comes with the same
reverseoption as that of the standard columns - The set of
one-eighthcolumns don't include widths and offsets for even numbers; for those, you should use theone-fourthcolumns and offsets that come with the standard grid - These are called "off-grid" columns because they don't align to the twelve-column grid; each of these sets will work best by themselves (with the noted exception of the
one-eighthcolumns); these will, however, work fine on their own or as sub-columns within standard-columned layouts
Arrange also comes with all of the features listed above in a format that doesn't use gutters. To remove the gutters from any grid, simply add the collapsed class to the container element (the element with a class of either row or container). Like this:
<div class="row collapsed">
<div class="four columns">
<!-- this would be a 1/3-width column -->
</div>
<div class="eight columns">
<!-- this would be a 2/3-width column -->
</div>
</div>As noted in some of the above sections, the full code of Arrange is perforated into six sections:
- The core grid with offsets
- The collapsed grid with offsets
- Reverse grid styles
- Reverse collapsed styles
- Off-grid equal-width columns
- Collapsed off-grid equal-width columns
If you're going to use gutters, only the core grid with offsets section is needed. If you're going to not use gutters, only the collapsed grid with offsets is needed. The rest of the sections can be removed to save on file size. To find the perforation points, find the following line:
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */Furthermore, the off-grid columns are grouped by their systems. If you only need one of the three systems (either one-fifth, one-seventh, or one-eighth), removing the other two systems is recommended to save on file size.
You'll find that these grids don't line up wonderfully well in older versions of Safari. They're serviceable, but not perfect. This is due to how the browser rounds decimal places to pick a pixel value to display. The smaller that you're dividing your grid, the more noticeable this will be — for example, making a grid with twelve one-twelfth columns won't line up very well against a grid of two one-half columns.
Most of the time you're not going to be using grid columns that small, so it shouldn't be a problem. However, know that it's a known thing and there's nothing Arrange can do about it.
Arrange is currently at version 1.3. The following are the changes that happened each step of the way:
-
v1.3
- Add 1/9th columns
-
v1.2
- Expand gutters to 4%
- Add the collapsed grid
-
v1.1
- Expand gutters to 3%
-
v1.0
- Initial release