Navbars with background images - tutorial

Pixabella

  • RSS Feed
  • Login
  • Home
  • Templates
  • Free Stuff
  • Privacy
  • Contact

Tuesday, January 22. 2008

Navbars with background images - tutorial

Navbar with background image
Image based navbar
I've produced a few sets of navbar images for free download dark, light, frosty, and original. In this tutorial I'm going to explain how to use them in your own site design.

This screenshot is taken directly from one of my free html templates. The HTML to create this is a basic list of links but without the CSS it looks quite boring, just a link, then a new line and another link and so on, however, once the CSS is added, you get an attractive navbar.
Start with a block of HTML code like this;

<div id="navigation">
  <div id="navbar_link">
    <ul>
      <li><a href="#" class="currentpage">Home</a></li>
      <li><a href="#">About Me</a></li>
      <li><a href="#">My Flickr</a></li>
      <li><a href="#">Contact</a></li>
    </ul>
  </div><!-- end of navbar_link -->
</div><!-- end of navigation -->

Each of the navbar images in the zipfiles has two parts to it. A top gradient and a bottom gradient, and when we add this image as the background to our navbar the CSS tiles it across the width of the containing div, and this looks really attractive on it's own, but then we shift the image upwards using CSS when the user hovers over one of the links to show the bottom gradient which is slightly darker in every case than the top gradient.

Here's the CSS you need;

#navigation {
  width: 960px;
  background: url(img/nav_dkblue.png) top center repeat-x;
  height: 31px;
  border-top: #58b2eb solid 1px;
  margin-bottom: 20px;}
#navbar_link {
  height: 30px;
  float: left;}
#navigation #navbar_link ul {
  float: left;
  height:30px;
  width: 100%;
  list-style-type: none;}
#navigation #navbar_link ul li {
  display: inline;}
#navigation #navbar_link ul li a {
  padding: 6px 15px;
  color: #fff;
  text-decoration: none;
  line-height: 1.6em;
  float: left;
  border-right: 1px solid #0c5684;
  text-decoration: none;
  font-size: 1.0em;
  font-weight: bold;}
#navigation #navbar_link a:hover {
  text-decoration: none;
  border-right: 1px solid #0c5684;
  color: #fff;
  background: #ddd url(img/nav_dkblue.png) center -33px repeat-x;}
.currentpage a {
  background: #ddd url(img/nav_dkblue.png) center -33px repeat-x;}

In your own site layout you'll need to change the width of #navigation if your design is not 960px wide. You'll also need to change some of the colors in the CSS since the colors listed here were picked to match the blue gradients in my template. Other than that, you should be able to use this CSS as it is.
in HTML and CSS   Comments (0)

Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments

    No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

 
 
 
 

Additional Sites

Categories

  • Blog
  • Cartoons
  • Favourite Music
  • Free Stuff
  • Free Templates
  • Gardening
  • HTML and CSS
  • Inkscape
  • Photo Favourites
  • Recipes
  • Travels

All categories

Archives

December 2008
November 2008
October 2008
September 2008
August 2008
Recent...
Older...

I Support Inkscape



Get Inkscape
Open Clip Art Library

Rabbit

© 2006-2008 Pixabella.Design by Pixabella. Valid XHTML, CSS