92
391 LAYOUT
CSS frameworks aim to make your life easier by providing the code for
common tasks, such as creating layout grids, styling forms, creating
printer-friendly versions of pages and so on. You can include the CSS
framework code in your projects rather than writing the CSS from scratch.
Css frameworKs
advantages
They save you from
●
repeatedly writing code for
the same tasks.
They will have been tested
●
across different browser
versions (which helps avoid
browser bugs).
disadvantages
They often require that you
●
use class names in your
HTML code that only control
the presentation of the page
(rather than describe its
content).
In order to satisfy a wide
●
variety of needs, they often
contain more code than you
need for your particular web
page (commonly referred to
as code “bloat”).
One of the most popular uses of
CSS frameworks is in creating
grids to layout pages. There
are several grid frameworks
out there, but the one we will
be looking at over the next few
pages is the 960 Grid System
(available at
www.960.gs
).
960.gs provides a style sheet
that you can include in your
HTML pages. Once our page
links to this style sheet, you can
provide the appropriate classes
to your HTML code and it will
create multiple column layouts
for you. The 960.gs website
also provides templates you can
download to help design your
pages using a 12 column grid. (In
addition, there is a variation on
the grid that uses 16 columns.)
To create a 12 column grid, an
element that contains the entire
page is given a
class
attibute
whose value is
container_12
.
This sets the content of the
page to be 960 pixels wide and
indicates that we are using a 12
column grid.
There are different classes for
blocks that take up 1, 2, 3, 4,
and up to 12 columns of the grid.
Each block uses class names
such as
grid_3
(for a block that
stretches over three columns),
grid_4
(for a block that
stretches over 4 columns) and
and so on through to
grid_12
(for a box that is the full width
of the page). These columns all
float to the left, and there is a 10
pixel margin to the left and the
right of each one.
There are several other grid-
based CSS frameworks available
online, such as those at:
blueprintcss.org
lessframework.com
developer.yahoo.com/yui/
grids/
introduCing the 960.gs Css frameworK