Home arrow DHTML arrow Page 2 - Cross Fading Navigation with DHTML
DHTML

Cross Fading Navigation with DHTML


Need to build smooth and attractive fading techniques into your web site using nothing more than script? This article will explain a proven cross-browser method, with ready-to-use code. If you think you don’t need this, you will conclude otherwise after reading the article!

Author Info:
By: Justin Cook
Rating: 5 stars5 stars5 stars5 stars5 stars / 10
March 10, 2004
TABLE OF CONTENTS:
  1. · Cross Fading Navigation with DHTML
  2. · Putting our Items in Place
  3. · Into the Code
  4. · The Fading Function
  5. · In Retrospect...

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Cross Fading Navigation with DHTML - Putting our Items in Place
(Page 2 of 5 )

First, we might need an area to contain main navigation. We’ll call it navRowMain, and place our top level items within:


<div id=”navRowMain”
 
<a href=/” onMouseOver=”swapNav);>Acme Inc.</a> |
 
<a href=/services/” onMouseOver=”swapNav);>Products Services</a> |
 
<a href=/success/” onMouseOver=”swapNav);>Success Stories</a>
</div>

You’ll notice that each item is a link. This is to allow for browsers incapable of handling the DHTML, perhaps on a PDA. This way, they still have the option of navigating to the default page for each section, which should provide hard links to where they want to go. You also see the call to the swapNav( # ) function for each onMouseOver event, but before we get into that, let’s build our sub-level navigation.


<div id="navRowSub">
  
<span id="nav1" class="subNav">
    
<a href=/>home</a> |
    
<a href=/company.aspx”>about the company</a> |
    
<a href=/locations.aspx”>locations</a> |
    
<a href=/contact.aspx”>contact</a>
  
</span
  
<span id="nav2" class="subNav">
    
<a href=/products.aspx”>products</a> |
    
<a href=/services/business.aspx”>business services</a> |
    
<a href=/services/residential.aspx”>residential services</a>
  
</span
  
<span id="nav3" class="subNav">
    
<a href=/success/>recent</a> |
    
<a href=/success/archives.aspx”>archived</a>
  
</span>
</div>

So, all of our items are in place, but before we jump into the code, we must first set the CSS styles. You can define whatever styles you need to; just make sure you include the following:


<style type="text/css">
<!--
  
.subNav {
    display
:none;
  
}
 
  
#navRowSub {
    height: 12px;
    filter: alpha( opacity = 100 );
    -moz-opacity:1;
  }
-->
</style>

Firstly, this tells each of our sub-level items to not display, because we’ve defined class="subNav" for each of them. Secondly, it defines the initial opacity of the whole block, which is essential to our modifying it. Unlike many styles, you can not modify the opacity filter on an object unless it has a defined initial value.

NOTE  You also have to set the height property, otherwise the script refuses to work in IE for some reason.


blog comments powered by Disqus
DHTML ARTICLES

- Text-Justify, Volume, and Other Style Sheet ...
- Ruby-Position, Size, and Other Style Sheet P...
- Padding, Pages, and More Style Sheet Propert...
- Marks, Orphans, and More Style Sheet Propert...
- Layouts, Margins, and Other Style Sheet Prop...
- Floats, Fonts, and Other Style Sheet Propert...
- Color, Filters, and Other Style Sheet Proper...
- Borders and More with Style Sheets
- Learning Style Sheet Properties
- Style Sheet Property Reference
- Completing a Noisy Image Application
- An Object-Based Approach to Building Noisy I...
- A Basic Method for Building Noisy Images
- Adding More Features to Sliders with the Scr...
- Using Sliders with the Scriptaculous Framewo...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials