Style Sheets
  Home arrow Style Sheets arrow Page 2 - 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 - Review: the initial source code for the CSS-based drop-down menu


    (Page 2 of 5 )

    As usual with many of my articles on web development, before I dive deeper into the modifications that need to be introduced to the initial version of this drop-down menu to make it function with Internet Explorer, I'd like to show you its complete source code. This will make it fresh in your mind, and give you a much better idea of how the menu does its thing.

    That being said, please have a look at the following code sample. It lists the full source code of the aforementioned menu, as it was built during the previous article of the series:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Example of CSS-based Drop-down menu (it doesn't work in IE)</title>

    <style type="text/css">

    /* 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 */

    li:hover ul{

    display: block;

    }

    </style>

    </head>

    <body>

    <ul>

    <li>About Us

    <ul>

    <li><a href="">Our Staff</a></li>

    <li><a href="">Why work with us?</a></li>

    <li><a href="">Our profile</a></li>

    <li><a href="">More details</a></li>

    </ul>

    </li>

    <li>Services

    <ul>

    <li><a href="">Graphic Design</a></li>

    <li><a href="">Web Design</a></li>

    <li><a href="">Web Programming</a></li>

    <li><a href="">Software Development</a></li>

    </ul>

    </li>

    <li>Products

    <ul>

    <li><a href="">Simple AJAX Library</a></li>

    <li><a href="">PHP Form Validator</a></li>

    <li><a href="">PHP MySQL Connector</a></li>

    <li><a href="">PHP Easy Pager</a></li>

    <li><a href="">PHP Form Factory</a></li>

    </ul>

    </li>

    </ul>

    </body>

    </html>


    If you take some time and test the above code sample on your non IE-based browser, then quite possibly you'll be pleased with how neatly it works. And the beauty of this menu rests on its complete independence from JavaScript for doing its business properly. Pretty good, right?

    However, you should also notice that whenever you test the menu with IE 6 and below, it simply won't work because of its lack of support for the "hover" CSS pseudo-class. Thus, the browser incompatibility must be fixed quickly, since it's highly desirable to get the menu working with IE as well.

    Of course, this correction will be achieved by adding a simple JavaScript function to the menu's structure, along with some additional CSS styles, which will come in handy for emulating the "hover" CSS support in Internet Explorer.

    Want to see how this will be done? All right, click on the link that appears 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 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek