Defining the Active State of Menu Sections for a CSS Sprite-Based Navigation Bar
In this third part of a series, I put the final touches on our sample navigation bar, which uses the functionality of CSS sprites to define the visual presentation of the “normal,” “hover” and “active” states of its sections. Constructing a graphic user interface like this is a two-step process. First, one creates a good-looking background image, and then tweaks its X and Y coordinates via CSS.
Defining the Active State of Menu Sections for a CSS Sprite-Based Navigation Bar - Defining the visual styles for the navigation bar's active state (Page 3 of 4 )
In reality, creating the visual presentation for the “active” state of each section of this example navigation bar is a two-step process that must be performed in the following order: first, it’s necessary to code the CSS styles that will give the sections their correct appearance, and then modify the bar’s structural markup to indicate which of these sections is currently viewed by the user.
In a real-world environment, this last step should be accomplished dynamically via a server-side language such as PHP or Ruby; however, for demonstrative purposes in this tutorial, I’ll be showing how to do this statically.
Having explained that, here’s the new set of CSS styles that uses the earlier CSS sprites to define the “active” state of the aforementioned sections:
As seen in the previous code sample, creating the “active” state of every bar section is done simply by assigning a class called “active” to its building links, which also requires modifying the X and Y coordinates of the corresponding background image to display the correct portion of it. Of course, at this point the inner working of this process should be pretty familiar to you, as it’s very similar to other examples shown in this and previous tutorials of the series.
Well, having created the CSS styles that define the “active” state of the sections of the navigational bar, we need to modify its markup, so this state can be properly reflected visually.
This process will be discussed in the following segment. Therefore, to learn more, click on the link below and keep reading.