Create two versions of a navigation menu ("navbar") —one vertcal, and one horizontal.
The first navbar will be vertical and look like this:
<div id="navigation">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">What's New</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">FAQ</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
Note the use of <a href="#">. These are dummy links, placeholders. They look and behave like links, but they don't go anywhere. To make this a working navigation menu, you'd have to replace the # signs with actual urls.
<style type="text/css">
<!--
-->
</style>
#navigation{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 0.8em;
font-weight: bold;
width: 8em;
border-right: 1px solid #333;
}
This first style rule sets the font family, size and weight for all of the navigation menu items. Of course, you can alter these to suit your own needs. The width sets the width of the navigation menu column; by using ems the menu is expandable. If you use pixels, the menu column will remain a fixed width, but the text will get bigger and perhaps break-out of their boxes. The border is optional, just a design element. Now add the following rules:
#navigation ul {
list-style: none;
margin: 0;
padding: 0;
}
#navigation ul li {
margin: 0;
}
Setting the list-style to none removes the bullets in the list. Then we remove the default margins and padding. Next a big style rule:
#navigation ul li a {
display: block;
padding: .2em .2em .2em .4em;
border-top: 1px solid #003;
border-left: 1px solid #369;
border-right: 1px solid #69C;
border-bottom: 1px solid #369;
background-color: #036;
color: #fff;
text-decoration: none;
width: 100%;
}
The key line here is display: block. That particular property makes the area around the words "clickable," not just the words themselves. As a result, they look and behave more like buttons. Setting the text-decoration to none removes the default underlines on the links. Setting the width to 100% ensures that each menu item expands to the width of the menu column. Everything else determines visual style—colors, borders, and padding. All can br modified to suit your design (the borders especially are optional). But we're not done quite yet:
html>body #navigation ul li a {
width: auto;
}
This line is a hack to make sure our menus format properly in Internet Explorer. Finally, we add the hover pseudo-style for rollovers. This will change the menu item colors when moused-over:
#navigation ul li a:hover {
background-color: #69F;
}
Once again, color choices can be changed to fit your design.
The second navbar will look like this:
<div id="navigation2">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">What's New</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">FAQ</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
#navigation2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 0.8em;
font-weight: bold;
padding: 0;
}
#navigation2 ul {
list-style: none;
margin: 0;
padding: 0;
width: 100%;
background-color: #036;
float:left; /* This is needed to keep the list element from collapsing */
}
So far it's very similar to the first menu. However, there are a couple significant differences. First of all, the width of this menu is 100% because we want it to stretch across the page. We've also added a float property; this does not appear to do anything, but it's important for it keeps the list from collapsing on itself when finished. Now add the following rule:
#navigation2 ul li {
float:left;
margin: 0;
}
This is the key; the float:left causes each menu item to line up horizontally, rather than vertically, which is normal for a list. Now let's style the links:
#navigation2 ul li a {
display: block;
margin: 0;
padding: 0 2em;
line-height: 1.8em;
color: #fff;
text-decoration: none;
}
#navigation2 ul li a:hover {
background-color: #69F;
}
Once again, we use the display:block to make the area around the list item "cliackable." We use line-height to give the navbar thickness (height). Colors and padding amounts can be adjusted according to your design.
Upon completion, give me a copy of your html file.
Week 9: Due, beginning of class.
Each navbar is worth 5pts.
5 pts |
Customized navbar. |
4 pts |
Did what was required. |
3 pts |
Complete, but contains one or more errors. |
0-2 pts |
Poor showing; mostly incomplete or full of errors. |