0

I want to create sub-menus in IE using CSS, but IE does not work with hover action. I don't want to use JavaScript.

How can I solve this? Is there another way to create sub-menus without CSS or JavaScript?

5 Answers 5

1

You can use the following code for IE6 based on jQuery library

if (jQuery.browser.msie && navigator.userAgent.toLowerCase().indexOf('msie 6') > -1){
    jQuery(document).ready(function() {
        jQuery('.menu li').hover(
            function() {
                jQuery(this).addClass('hover');
            },

            function() {
                jQuery(this).removeClass('hover');    
            }
        );
    });
}

Please change the selector ".menu li" to yours and wrote in CSS in the following way .menu li:hover, .menu li.hover { ... }

Sign up to request clarification or add additional context in comments.

Comments

0

What do you mean IE does not work with hover action? IE6 and earlier only supports :hover on A tags and IE7 and later supports it on any tag. It is definitely possible to make 100% CSS menus. Here's what I found with a quick Google search.

http://www.surguy.net/menu/index.html

1 Comment

Also it applies :hover to non ATags
0

IE6 and below supports the :HOVER pseudo-class on <a> tags only. You can make the <a> tag behave like a block level element (I assume you are currently using <ol><li>) by applying the following CSS:

a.submenu { display: block; }

Comments

0

I highly recommend using whatever:hover, an HTC extension that enables the use of the :hover pseudo-class on all elements, not just anchors, in IE6.

Usage is simple. Add this to the header, changing the path to reflect your setup:

<!--[if lte IE 6]>
    <style type="text/css">
        body{behavior:url(path/to/iehover.htc);}
    </style>
<![endif]-->

That's it!

1 Comment

@cpharmston: Only works when JavaScript is enabled. An unobtrusive solution is preferred.
0

I found this page but didn't have a chance to see if it was really CSS only. http://www.cssplay.co.uk/menus/final_drop.html

My original method seems to no longer work on most browsers and wouldn't validate.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.