CSS Tabs Rollover Menu
Using a tabbed rollover menu in the header of your website can add functionality, as well as making the navigation look good. Doing this in CSS means that you can use it to it’s greatest capacity, easily add or remove tabs and change the colour in different styles.
19+ Million Digital Assets, With Unlimited Downloads
Get unlimited downloads of 19+ million design resources, themes, templates, photos, graphics and more. An Envato subscription starts at $16 per month, and is the best unlimited creative subscription we've ever seen.
1. Decide on the Navigational Elements and Colours
It is initially important to decide on which tabs you will want to place on your site, and what the colour scheme will be. You need to have an idea of how many tabs there will be, and what the default background and rollover background colour will be. Make a note of these!
2. How It Works
The tab area is set as a layer, to hover over a specific part of the page – you set this manually, based on where you would like it to be located.
Simply take the CSS code (see below), and change the commented values to fit in with the colour scheme of your website. You can go deeper and change elements such as the height, width and position of the menu bar if you want.
3. Download the CSS Code
Download a copy of the CSS code, then link to it as explained below.
4. Insert the CSS file into your HTML Code
Upload the tabsample.css file to your server, then place the following line in your area to link to the stylesheet.
<link rel="stylesheet" type="text/css" href="tabsample.css" />
5. Place the Tabs in your HTML Code
OK, so you’ve got all the formatting done for tabs in the CSS file, now you just need to place the correct HTML code in your index.php page.
For each tab you want to display, enter:
<ul id="supernav"> <li<?php if ($page=="home") { echo " id="selected""; } else {} ?>> <a href="/index.php" title="The Weblog">Blog</a> </li> -- Repeat as necessary for other tabs -- </ul>
For each different tab, change the following:
"home"
– this is a one word description of the page (for the reason why, see below)
"/index.php"
– this is the link to that particular page
"The Weblog"
– a description of the page you’re linking to
Blog
– the word you want to appear in your navigation bar as a link
Note: It doesn’t really matter where you place this source code, as the position they appear in is set in the CSS file. I would recommend somewhere near the header area.
6. What’s the PHP for?
The PHP code in the above line allows you to have an alternative look and feel for the tab on the current page (see the ‘Blog’ tab above?) Simply place this line underneath the
<?php $page="home"; ?>
As before, change "home"
section to match that on the tab area.
If you do not want to use this functionality or are not using PHP in your pages, replace the code in Step 5 with the following:
<li><a href="/index.php" title="The Weblog">Blog</a></li>
You should end up with a menu looking similar to the one at the top of this page in no time. It’s a simple method, and spices up your pages navigation!