h1. Blueprint CSS Framework Tutorial Welcome to this tutorial on Blueprint. It will give you a thorough intro to what you can do with the framework, and a few notes on what you shouldn't do with it. Let's get started. h2. About Blueprint Blueprint is a CSS framework, designed to cut down on your development time. It gives you a solid foundation to build your CSS on top of, including some sensible default typography, a customizable grid, a print stylesheet and much more. However, BP is not a silver bullet, and it's best suited for websites where each page may require it's own design. Take a look at existing BP pages before deciding if the framework is right for you. You may also check out the test files in the @tests@ directory, which demonstrates most of the features in Blueprint. The word "framework" may be a bit misleading in this context, since BP does not make suggestions on how you should organize or write your CSS. It's more like a "css toolbox" with helpful bits and pieces, from which you may pick and choose based on your needs. h2. Structural Overview From the bottom up, here are the CSS layers in Blueprint: # *CSS reset*: Removes any default CSS rules set by each browser. # *Typography*: Gives you some nice default typography and colors. # *Grid*: Provides a set of CSS classes for making grid layouts. The second part of Blueprint are the scripts, which lets you customize most aspects of the framework, from column count and widths, to output paths and CSS class namespaces. We have two scripts: # *Compressor*: For compressing and customizing the source files. # *Validator*: For validating the Blueprint core files. That's the quick overview, so now we can finally get into the details. First, we'll take a look at the CSS in Blueprint. We'll then move on to the scripts, where I'll show you how to customize the framework. h2. Setting Up Blueprint To use Blueprint, you must include three files in your HTML: * @blueprint/screen.css@: All CSS for screen, projection viewing. * @blueprint/print.css@: A basic stylesheet for printing. * @blueprint/ie.css@: A few needed corrections for Internet Explorer To include them, use the following HTML (make sure the href paths are correct):
Remember to add trailing slashes if you're using XHTML (" />"). h2. Using the CSS in Blueprint As mentioned before, there's basically three layers of CSS in Blueprint. The first two layers, the browser CSS reset and the default typography, apply themselves by changing CSS of standard HTML elements. In other words, you don't need to change anything in these files. If you for instance want to change the font size, do this in your own stylesheet, so that it's easy to upgrade Blueprint when new versions arrive. h3. Classes for Typography While the typography of Blueprint mainly applies itself, there's a few classes provided. Here's a list of their names and what they do:
In addition to the spans, there are two important classes you need to know about. First of all, every Blueprint site needs to be wrapped in a div with the class @.container@, which is usually placed right after the body tag. Second, the last column in a row (which by default has 24 columns), needs the class @.last@ to remove its left hand margin. Note, however, that each @.span-24@ don't need the @.last@ class, since these always span the entire width of the page. To create basic grids, this is all you need to know. The grid CSS however, provides many more classes for more intricate designs. To see some of them in action, check out the files in @tests/parts/@. These files demonstrate what's possible with the grid in Blueprint. Here's a quick overview of the other classes you can use in to make your grid:The headerThe first columnThe center columnThe last columnThe footer
You may also nest columns to achieve the desired layout. Here's a setup where we want four rectangles with two on top and two below on the first half of the page, and one single column spanning the second half of the page:The first columnThe second columnThe third columnThe fourth (last) column
Try this code in your browser it it's difficult to understand what it would look like. To see more examples on how to use these classes, check out @/tests/parts/grid.html@. h2. The Scripts Blueprint comes with two scripts: one for compressing and customizing the CSS, and one for validating the core CSS files, which is handy if you're making changes to these files. h3. The Validator The validator has a fairly simple job - validate the CSS in the core BP files. The script uses a bundled version of the W3C CSS validator to accomplish this. To run it, you'll need to have Ruby installed on your machine. You can then run the script like so: @$ ruby validate.rb@. Note that there are a few validation errors shipping with Blueprint. These are known, and comes from a few CSS hacks needed to ensure consistent rendering across the vast browser field. h3. The Compressor As the files you'll include in your HTML are the compressed versions of the core CSS files, you'll have to recompress the core if you've made any changes. This is what the compressor script is for. In addition this is where you customize the grid. To customize the grid, a special settings file is used, and the new CSS is generated once you run the compressor. The new compressed files will then reflect your settings file. To recompress, you just have to run the script. This will parse the core CSS files and output new compressed files in the blueprint folder. As with the validator, Ruby has to be installed to use this script. In the @lib@ directory, run: @$ruby compress.rb@ Calling this file by itself will pull files from @blueprint/src@ and concatenate them into three files; @ie.css@, @print.css@, and @screen.css@. However, argument variables can be set to change how this works. Calling @$ruby compress.rb -h@ will reveal basic arguments you can pass to the script. h3. Custom Settings To learn how to use custom settings, read through the documentation within @lib/compress.rb@Top leftTop rightBottom leftBottom rightSecond half of page