Styling the Document - Page 2
July 19, 2002
Basically, we have two main tasks ahead of us:
Getting Back to Square One
Before we get down 'n' dirty with the links, let's quickly reproduce
the original basic design look in CSS. Because we have the HTML file to guide
us, we can just rewrite the styles to match what we had before (see
Figure
4.3).
<style type="text/css">
body {background: #CEC; color: black;}
td#navbuttons {background: #ACA; padding: 0;
border: 2px solid #797;}
td#main {background: #FFD; color: black;
border: 2px solid #797;}
</style>
Figure 4.3
The first step in re-creating the basic design.a
The space between the two cells is now 4 pixels thick, thanks to the fact
that there are two adjacent borders and each is 2px thick. We need to
reduce one of them to zero or both to be 1 pixel wide. Let's try the
latter:
td#navbuttons {background: #ACA; padding: 0;
border: 2px solid #797; border-width: 2px 1px 2px 2px;}
td#main {background: #FFD; color: black;
border: 2px solid #797; border-width: 2px 2px 2px 1px;}
Alternate Border Effects
We also could have created the borders around the cells by setting a background
color for the table itself and then setting a value (such as 2) for
the cellspacing attribute. Although this approach works in some cases,
it also tends to rob the designer of flexibility because it enforces a single
padding on all cells instead of allowing different amounts of padding on different
cells. That's why we're avoiding it here.
We should also set the vertical and horizontal alignment of the content within
the cells. We know that both the icons and the text should be aligned to the
top of their table cells, and the icons ought to be center aligned within their
cells (see Figure 4.4). Thus:
body {background: #CEC; color: black;}
table#inform td {vertical-align: top;}
td#navbuttons {background: #ACA; padding: 0;
border: 2px solid #797; border-width: 2px 1px 2px 2px;
text-align: center;}
Figure 4.4
Everything's back (more or less) to where we started.
The only thing left to do would be to reproduce the effect of the attribute
cellpadding="5" in the original file. We could do that with
padding, but we're going to put it off until later when we have a
better idea of how the layout might be affected by padding on the cells.
Upgrading the Title
Before we get to the links, we need to make the title fit in with the rest
of the design. The design department, you might recall, suggested that we eliminate
the space between the text and the table (see Figure
4.5). They probably meant that we should set the bottom margin to zero,
but let's take them literally at their word:
body {background: #CEC; color: black;}
h1 {margin-bottom: -0.25em;}
table#inform td {vertical-align: top;}
Figure 4.5
Get rid of the space between text and table? You got it!
It still doesn't fit in too well, so let's change the color to
match the medium-green borders and also switch it to be a sans-serif font. While
we're in the area, we'll also boldface it and make sure it's
twice the normal text size.
body {background: #CEC; color: black;}
h1 {margin-bottom: -0.25em;
font: bold 200% Arial, sans-serif; color: #797;}
table#inform td {vertical-align: top;}
There's one more thing that would make this work even better, and that's
a thicker top border on the table. Let's make it easy and just add the
border to the table itself instead of messing with the table cells (see Figure
4.6).
h1 {margin-bottom: -0.25em;
font: bold 200% Arial, sans-serif; color: #797;}
table#inform td {vertical-align: top; border-top: 3px solid #797;}
Now it looks like the title is rising from the border itself or maybe was
carved out of the same stuff. Whatever visual metaphor it invokes, it's an
interesting effect. We'll keep it and see what the client thinks.
Figure 4.6
Making the title part of the organic whole.
Eric Meyer on CSS: Mastering the Language of Web Design
Eric Meyer on CSS: Mastering the Language of Web Design
The Icons - Page 3
|