Now that you know all about Find and Replace, regular expressions, and stored queries, you can strip the verbose comments from the style sheet created by the Dreamweaver CSS layout in the exercises in the first half of this chapter.
The regex to describe a CSS comment looks like this:
/\*[\s\S]+?(?=\*/)\*/
Because this regex is so useful—and easy to mistype—I have created a stored query to automate the process. It’s called css_comment_remover_v3.dwrand is in the examples/
ch05 folder. Simply load it as described in the previous section. To remove all the CSS comments in a single operation, click Replace All. This removes all comments, including any CSS hacks that look like comments. If you’re in any way uncertain, remove the com- ments selectively by clicking Find Next to highlight the first one. Then click Replace to remove it or Find Nextto move to the next one.
Dreamweaver always remembers your last Find and Replace operation, so these settings will be displayed the next time you open the Find and Replacedialog box. Delete the reg- ular expression from the Find field, and deselect the Use regular expression checkbox (unless you plan to use another regex). This final point is very important. When a Find operation fails for no obvious reason, it’s usually because you have selected the Use regular expressioncheckbox by accident.
Chapter review
Depending on your knowledge of CSS, this chapter is likely to have been relatively easy or something of a nightmare. If you fall into the latter category, I encourage you to persevere.
It can take a long time for CSS to sink in. If you find it difficult to understand how to build
5
your own style sheets, download a page from a site you admire, complete with images and style sheets. Then use the CSS Styles panel to change or delete individual properties.
Watch the effect of each change. Also select different parts of the page to analyze the cas- cade of styles.
Mastering the CSS Stylespanel takes time and patience, but it will reward you in the end.
Remember that Currentmode shows the cascade as it affects the current insertion point or selection. Use the Tag selector at the bottom of the Document window to highlight spe- cific elements, and then use the Summary for Selectionand Rulespanes to drill down to the CSS rules you want to inspect or edit.
You’ll get some more practice with the CSS Stylespanel in the next chapter when you integrate a Spry menu bar into the page layout. The menu bar and other Spry widgets come with their own predefined style sheets, so you need to know how to adapt them to blend in with your own design.
T H E S P R Y M E N U B A R
Efficient and attractive navigation is an important element in every website. The Spry menu bar combines CSS and JavaScript (using Spry, Adobe’s implementation of Ajax) to create a flexible menu with flyout submenus that remains accessible even if JavaScript is turned off. In essence, it’s an unordered list with optional nested lists for submenus. It comes in two versions: horizontal and vertical. Figure 6-1 shows what the horizontal ver- sion of the Spry menu bar looks like when integrated into the page built in the previous chapter.
Figure 6-1.You can easily integrate the Spry menu bar into a page by making a few adjustments to the CSS.
Although you can insert a Spry menu bar in seconds, the downside is that styling it requires a good understanding of CSS. Knowing which style rules to change—and which to leave alone—presents more of a challenge. This process has been made considerably eas- ier in Dreamweaver CS4 by the introduction of Live view and Code Navigator.
In this chapter, you’ll learn about the following:
The structure of the Spry menu bar How to insert and remove a Spry menu bar The style rules that control a Spry menu bar
How to customize a Spry menu bar using Live view and Code Navigator
By the end of the chapter, you’ll be able to transform the rather bland default design of a menu bar into something much more elegant like the menu in Figure 6-1. Because the Spry menu bar is styled with CSS, this chapter assumes you’re familiar with the CSS Styles panel, which was described in detail in Chapter 4.