Creating a
|
Creating the Background ImagesThis layout uses two background images to give the illusion of column colors. The images must be wide enough to ensure they fill the largest screen. Here, they are 2000px wide. The first image will be used to create the #content and #news column background colors.
The second image will be used to create the
#nav
column background
Figure 21.2. Diagram showing the background images.
|
Styling the <body> ElementNow that the layout grid and images are finished, you can begin coding the page. The first step is to force the contents of the page up against the edges of the browser window. To do this, you must set both margin and padding to .
You can set both
font-
The
Listing 21.3. CSS Code for Styling the <body> Element
body
{
margin: 0;
padding: 0;
font: 90% arial, helvetica, sans-serif;
background: #387A9B;
color: #333;
}
Figure 21.3. Screenshot of the styled <body> element.
|
Styling the <h1> ElementThe <h1> element will be used to create the top banner.
First, the
Standard <h1> elements have predefined top and bottom margins. To force the <h1> element into the top corner of the browser window, these margins must be set to . To create space around the <h1> content, padding: .5em 3%; is used. This will put .5em of padding on the top and bottom of the content, and 3% on the left and right edges. Finally, a border is applied to the bottom of the element using border-bottom: 5px solid #387A9B; as shown in Listing 21.4 and Figure 21.4. Listing 21.4. CSS Code for Styling the <h1> Element
body
{
margin: 0;
padding: 0;
font: 90% arial, helvetica, sans-serif;
background: #387A9B;
color: #333;
}
h1
{
background: #D36832;
color: #FFF;
margin: 0;
padding: .5em 3%;
border-bottom: 5px solid #387A9B;
}
Figure 21.4. Screenshot of the styled <h1> element.
|