In this fifth article of a seven-part series, I demonstrate how to use a set of CSS sprites to define the visual style corresponding to the “normal” state of a navigation bar of a fictional blog site. The most complex facet of this process was to create the background image containing the corresponding sprites; the rest of the procedure merely involves manipulating the image’s X and Y coordinates via CSS.
Styling a Blog`s Links Bar with CSS Sprites - Binding the CSS styles to the blog's structural markup (Page 4 of 4 )
If you're anything like me, then you wish to see how the navigation bar of this sample blog web page looks in its normal state. Below I listed for you the full source code of the page, this time including the set of CSS styles coded in the previous segment:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div id="footer">
<h2>Footer section</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
</body>
</html>
Mission accomplished, at least for the moment. At this point, it's clear to see that building a sketchy links bar using CSS sprites is indeed a straightforward process that can be tackled with only minor headaches. Of course, the above example would be somewhat incomplete if I don't show you a cropped view of the bar in its current state, so here it is:
As I said before, one of the biggest pros to using CSS sprites is their inherent flexibility. Whether you need to construct a sketchy navigation bar like the one shown above or one that has a more corporate look, the process remains nearly the same. It first requires that you create the CSS sprite background image and then manipulate it via CSS.
Final thoughts
In this fifth chapter of the series, I demonstrated how to use a brand new set of CSS sprites to define the visual style corresponding to the "normal" state of the navigation bar of this fictional blog site. As you saw before, the most complex facet of this process was to create the background image containing the corresponding sprites, since the rest of the procedure was reduced to manipulating the image's X and Y coordinates via CSS.
With the "normal" state of the bar already set, the next logical step is defining its appearance when the mouse is placed over each of its sections. Fortunately, this topic will be covered in the next article. Don't miss it!
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.