Spring.Into.HTML.and.CSS [Electronic resources]

Barry J. Rosenberg

نسخه متنی -صفحه : 171/ 133
نمايش فراداده

Horizontal List-Based Navigation with Color

In the last section, you used the display: block; property to turn the anchor element from an inline element to a block element. Using the display: inline; property, you can make lists operate inline, which means they'll display horizontally (see Example 10-13).

Example 10-13. Markup and CSS for a horizontal list navigation using color effects
[View full width]

<!DOCTYPEl PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/l1/DTD/l1-transitional.dtd">
<l xmlns="http://www.w3.org/1999/l">
<head>
<title>working with style</title>
<style type="text/css">
body {font: 14px Georgia, Times, serif; color: black; }
ul#navlist {margin-left: 0; padding-left: 0; white-space: nowrap;}
#navlist li {display: inline; list-style-type: none;}
#navlist a { padding: 3px 10px; }
#navlist a:link, #navlist a:visited {color: white;  background-color: orange;
 text-decoration: none;}
#navlist a:hover {color: orange; background-color: yellow; text-decoration: none;}
</style>
</head>
<body>
<div id="navcontainer">
<ul id="navlist">
<li><a href=">Home</a></li>
<li><a href=">Products</a></li>
<li><a href=">Services</a></li>
<li><a href=">About Us</a></li>
<li><a href=">Contact</a></li>
</ul>
</div>
</body>
<l>

This results in a very nice horizontal navigation bar (see Figure 10-19).

Figure 10-19. Using a list and color effects to achieve horizontal list-based navigation.