Putting on the Final Touches
Our page is looking great and with just a little more styling, some bug busting and clean up, we're done!
The Plain Vanilla Links
We've already made our links white. In case there's a user agent that doesn't give them underlines by default, we'll add underlines. We'll set a pale gray to indicate a link that's been visited and for our hover style, we'll simply remove the underline.
- Click into a link on the page, select the a element and add the underline value.
Create a grouped selector for the hover pseudo-class along with the active and focus pseudo-classes. Remove the underline.
a { color: #FFF; text-decoration: underline; } a:hover, a:active, a:focus { text-decoration: none; }
Limiting the Page Width
Our very last chore in the main CSS page is to give our overall container a minimum width and maximum width. It's not imperative, but it is a good idea to limit the width, especially when you're dealing with a three-column layout. On the small size end of the spectrum, you want to be sure your columns remain readable and don't get everything squished and flowing out of bounds. On the large size end, you want to be sure your line length remains readable. Lines that run too long become very hard to read.
Select the container div. Add a min-width of 770px and a max-width of 1500px.
The max-width value is arbitrary really. We opened the page really wide, looked at the length of the lines, moved it down to the point where it looked readable and measured. The max we felt was readable was 1500px. (Yes, there are more scientific ways to deal with line length issues and many studies have been done. Search the web to read more about the subject.)
If the viewport is wider than 1500px, the dark blue body background color (that shows from the footer down) will appear on the right side. It's not especially attractive in this case, so we'll center the container to give it a more balanced look.
Since the container already has a width, all we need to center it is auto left and right margins. (You might as well give the top and bottom zero as well.)
#container { width: 100%; text-align: left; font-size: 80%; min-width: 770px; max-width: 1500px; margin: 0 auto; }
Figure 4.43 Our page shown with a really, really wide viewport.
If IE Ain't Happy, Ain't Nobody Happy
We've now completed the page for browsers that render well to standards. Go ahead and preview it in a few browsers. If you're on a PC (or if you have IE available to you on the Mac), you'll probably see a lovely page until you view it in Internet Explorer. Well, IE6 or older. IE7 actually renders just fine.
Figure 4.44 IE6 is a real beauty!
As scary as it looks, the fix really isn't that tough. In fact, both things that need to be added are related to the one thing you should remember if you forget everything else—hasLayout. If hasLayout isn't triggered in some way, IE is a very unhappy camper.
Let's analyze our blown-up page. The first thing we see is that the horizontal navigation bar has no color. And furthermore, we have a sneaking suspicion that the fact that the vertical navigation is sitting to the right of the horizontal navigation bar (which comes next in the flow) further indicates the issue is related to the horizontal ul element. We'll do the first thing any good web developer should pull from their arsenal when working with IE issues: zoom:1.
The zoom property, as we explained in the CSS review chapter, is a proprietary Microsoft property. Setting it to 1 changes nothing. No harm, no foul. But it fixes many a hasLayout (dimensional) issue, so it's the first thing we'll try. Since it is proprietary and it won't validate, it should always go into an IECC. Since IE7 is not showing the same issues, we'll put this into our <!--[if lte IE 6]> IECC.
In the <!--[if lte IE 6]> IECC that already exists in the head, add the same rule we wrote in our style sheet for the horizontal navigation—#header ul and give it the declaration zoom: 1;.
The fact that there's no width or height on the navigation, as well as any other properties that trigger hasLayout, was our clue that this is where we need to go first. Refresh the page if you have IE6. Things are looking better. The only problem we see left is the space in the left side vertical menu.
Again, our links don't have any dimension and they're set to display:block. This triggers a white space bug in IE. Guess what the fix is? Yup, you got it. The hasLayout trigger, zoom:1. Add the #sidebar1 li a rule, creating a grouped rule, to the rule we just created for the zoom:1 fix.
<!--[if lte IE 6]> <style type="text/css"> #header ul, #sidebar1 li a { zoom: 1; } #sidebar2 { height: 145px; } </style> <![endif]-->
The bugs are squashed flat.
Take a moment to do a last tidy to your CSS. Move the rules around in the All pane of the CSS Styles panel to organize them as we've done before. The grouped selectors starting with a:hover should follow the a element selector. Move the new footer selectors into the footer section.
You've probably wondered about those comments Stephanie put into the CSS documents for the CSS layouts. They're a great learning tool if you need them as you build, but more often than not, you'll want to lighten up the page before you put it on the server. (After you get really comfortable, you may want to remove them from the beginning!) Dreamweaver doesn't come with a built-in way to remove them, but you can remove them with a regular expression in the Find and Replace dialog.
If you haven't learned to write regular expressions yet, or really don't care to, David Powers has come to your rescue. He's provided a free extension (with instructions) that gives you a simple way to delete them all in one fell swoop. If you still need the comments but want to lighten up the page (or hide the training wheels from your client), make a copy of your page to keep. And strip the comments from the document that you're placing on the server.
When we strip the comments at the end of the project, we take a brief moment to comment the main sections of the CSS document to make it easier to find what we need later.
Your page is complete! Take a look at it in your browser and admire your work.
So what have you've accomplished in this chapter? You've learned how to deal with percentage-based layouts and to overcome the challenges that margin and padding give in these layouts. Additionally, you've learned how to effectively use background images within percentage-based columns as well as creating a liquid faux column; you can style lists, including both horizontal and vertical menus without the use of inline images; and create a current page indicator. Finally, we've explored the use of Photoshop CS3, together with Dreamweaver CS4 to optimize or streamline the production process.