Tabbed navigation is very popular—it's clean and easy to use. Tabs can be created a number of ways, from simple HTML + CSS methods to more complex graphics-controlled-by-javacript techniques. In this exercise I present a method that falls somewhere in between: it uses graphics with rollover effects, but it controls them entirely with CSS. When they're finished they will look something like this:
Each slice should be exactly 150 pixels wide; you can check the width of the slices and adjust them accordingly in the Dimensions window.
<div id="mainNav">
<ul>
<li id="item1Tab"><a href="#" id="current"><span class="noShow">Item 1</span></a></li>
<li id="item2Tab"><a href="#"><span class="noShow">Item 2</span></a></li>
<li id="item3Tab"><a href="#"><span class="noShow">Item 3</span></a></li>
<li id="item4Tab"><a href="#"><span class="noShow">Item 4</span></a></li>
<li id="item5Tab"><a href="#"><span class="noShow">Item 5</span></a></li>
</ul>
</div>
<style type="txt/css">
#mainNav ul {
margin:0;
padding:0;
list-style-type:none;
}
#mainNav ul li{
display: inline;
float: left;
margin:0;
padding:0;
}
</style>
The first style rule hides the bullets in the list and removes the indent. The next style rule turns the vertical list column into a horizontal row.
#item1Tab a:link, #item1Tab a:visited {
background-image: url(images/tab1.png);
background-repeat: no-repeat;
background-position: 0px 0px;
display:block;
margin:0;
padding:0;
width:150px;
height:50px;
}
#item1Tab a:hover {
background-image: url(images/tab1.png);
background-repeat: no-repeat;
background-position: 0px -50px;
display:block;
margin:0;
padding:0;
width:150px;
height:50px;
}
#item1Tab #current {
background-image: url(images/tab1.png);
background-repeat: no-repeat;
background-position: 0px -100px;
display:block;
margin:0;
padding:0;
width:150px;
height:50px;
}
All three styles are nearly identical. Each creates a 150px by 50px box around Item1 and then adds the tab1 graphic as a background. However, note the changes to the background-position line: the first or "normal" state shows only the top third of the graphic (the graphic is 150 pixels tall, put it's showing only 50 pixels of it); the second "hover" state shows the middle third; and the final style shows the bottom third of the graphic. Thus when one rolls-over the tab it changes, essentially 'sliding' up and down into the proper position.
.noShow {
display: none;
}
Due: Beginning of class, week 4 .