Style Sheets
  Home arrow Style Sheets arrow Page 3 - Fixing Browser Incompatibilities in a CSS ...
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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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? 
STYLE SHEETS

Fixing Browser Incompatibilities in a CSS Drop-Down Menu
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2008-10-22

    Table of Contents:
  • Fixing Browser Incompatibilities in a CSS Drop-Down Menu
  • Review: the initial source code for the CSS-based drop-down menu
  • Fixing browser incompatibilities
  • Adding JavaScript to correct browser incompatibilities
  • The modified version of the CSS-based drop-down menu

  • 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


    Fixing Browser Incompatibilities in a CSS Drop-Down Menu - Fixing browser incompatibilities


    (Page 3 of 5 )

    As I expressed in the previous section, this CSS-based drop-down menu needs the assistance of JavaScript to work with Internet Explorer, in this way solving this relevant incompatibility issue.

    Nevertheless, before coding any JavaScript snippets, I'm going to modify the original set of CSS styles that corresponds to the menu, so each of its items can be easily targeted via client-side scripting to hide and show them alternatively.

    If the previous explanation sounds rather confusing to you at first, please have a look at the following CSS styles. They have been slightly changed to make the menu's items suitable for being manipulated via JavaScript.

    Here's how the aforementioned CSS styles now look:


    /* reset body styles */

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    /* style unordered list */

    ul{

    padding: 0;

    margin: 0;

    list-style: none;

    }

    /* style menu items */

    li{

    float: left;

    position: relative;

    width: 10em;

    }

    /* position and hide drop-down menu */

    li ul{

    display: none;

    position: absolute;

    top: 1em;

    left: 0;

    }

    li > ul{

    top: auto;

    left: auto;

    }

    /* display drop-down menu (add an 'over' class attribute to list items for IE */

    li:hover ul,li.over ul{

    display: block;

    }


    As you can see, the most significant change I introduced in the above CSS styles consists of adding an "over" class to all of the menu items. This will allow them to be hidden or displayed when the mouse is over its respective top-level element by the means of a simple JavaScript function.

    Naturally, this modification would be completely unnecessary if Internet Explorer offered decent support for the "hover" CSS pseudo class, but for the moment you'll have to settle for things being just the way they are.

    All right, now it's time to define a simple JavaScript function that will hide/display the corresponding menu items in Internet Explorer (obviously, this isn't required for most non-IE based browsers), so if you want to see how this function will look, please click on the link below and keep reading.

    More Style Sheets Articles
    More By Alejandro Gervasio


       · In this second chapter of the series, support for the CSS hover pseudo class is...
       · I really enjoyed your article, and plan on using it in future website designs. The...
       · Thanks Alicia for the words on my article. Of course that specific CSS classes...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek