JavaScript
  Home arrow JavaScript arrow Page 3 - Controllable Navigation Bars with JavaScri...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Controllable Navigation Bars with JavaScript, Part II
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2005-03-28

    Table of Contents:
  • Controllable Navigation Bars with JavaScript, Part II
  • Dealing with those details
  • Cleaning up the CSS styles
  • JavaScript to the rescue: the improved "switchBar()" function

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Controllable Navigation Bars with JavaScript, Part II - Cleaning up the CSS styles


    (Page 3 of 4 )

    First, let's focus our attention on the CSS code. As we previously mentioned, we need to get rid of all of the fixed heights, as well as the value "auto" specified for the width of the "content" <div>. Starting out from that point, let's see how the new CSS styles look:

    <style type="text/css">

    body {

    margin: 0;

    }

    #navbar {

    float: left;

    width: 15%;

    background: #ccf;

    padding: 10px;

    border-left: 1px solid #000;

    border-bottom: 1px solid #000;

    }

    #switchbar {

    float: left;

    width: 18px;

    background: #fff url("tab_left.gif") repeat-y center center;

    padding-top: 10px;

    padding-bottom: 10px;

    }

    #content {

    float: left;

    width: 60%;

    padding: 10px 5px 10px 5px;

    }

    #headlines {

    float: right;

    width: 15%;

    background: #ccf;

    padding: 10px;

    border-left: 1px solid #000;

    border-right: 1px solid #000;

    border-bottom: 1px solid #000;

    }

    </style>

    As you can see, we've completely removed the fixed heights from the contextual selectors, and replaced the value "auto" for the "content" container's width, by specifying a value of "60%". You can play around with this, assigning different measures according to your specific needs. The rest of the code remains nearly the same, sticking to the initial example, basically styling the <div> elements with borders and background colors, and setting up the style for the "switcher" bar. Now, our styles look much cleaner.

    Regarding the HTML markup, it's identical to the example illustrated in the first part of these series. But let's take a look at its listing:

    <div id="navbar">

    <h1>Navbar Section</h1>

    <p>Content goes here...</p>

    </div>

    <div id="headlines">

    <h1>Headline Section</h1>

    <p>Content goes here...</p>

    </div>

    <div id="content">

    <h1>Page Name</h1>

    <h2>Section title</h2>

    <h3>Article title</h3>

    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec molestie.

    Sed aliquam sem ut arcu. Phasellus sollicitudin. Vestibulum condimentum

    facilisis nulla. In hac habitasse platea dictumst. Nulla nonummy. Cras quis

    libero. Cras venenatis. Aliquam posuere lobortis pede. Nullam fringilla

    urna id leo. Praesent aliquet pretium erat. Praesent non odio. Pellentesque

    a magna a mauris vulputate lacinia. Aenean viverra. Class aptent taciti

    sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.

    Aliquam lacus. Mauris magna eros, semper a, tempor et, rutrum et, tortor.</p>

    </div>

    Certainly, the HTML looks really simple; it just defines the three main <div> elements that will determine the overall page layout. In this case, I opted to build a three-column liquid design, but as usual, it's up to you to choose the best approach for the way that page elements will be laid out.

    So, now that we've cleaned up the CSS styles and listed the corresponding markup, it's time to rewrite the original JavaScript function, in order to make it work gracefully with the new improvements applied to the source code. Hopefully, the target is not too hard to hit.

    More JavaScript Articles
    More By Alejandro Gervasio


       · Over this second part, the article deals with some browser incompatibilitiesand...
     

    JAVASCRIPT ARTICLES

    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway