Tuesday, April 13, 2010

Drupal Nice Menus hidden behind parent

Drupal is a great open source CMS package. There are some bugs in it with additional modules but those are being fixed by the community. One nasty bug is the one where you use nice menus and the second level menu items hide behind parent items in IE. Nice menus work perfect in Firefox and Safari but in IE they behave oddly. I had this issue with one of my websites and after a long research on it I found the fix. All you need to do is
to add following function to your nice_menus.js javascript file. This function takes care of the z-index property properly. I fixed my issue with this code and hope this will come handy for you too. Please comment if this solves your problem.

window.onload = function() {
  if (document.all) {
    var targetZIndex = 1000;
    var parent = document.getElementById('nice-menu-1');
    var children = parent.getElementsByTagName('li');
    for (var i = 0; i < children.length; i++) {
         children[i].style.zIndex = targetZIndex;


  1. sorry, but I'm not great with javascript... where does this go within the nice_menus.js file?

    // $Id: nice_menus.js,v 1.21 2010/06/18 06:14:12 vordude Exp $

    // This uses Superfish 1.4.8
    // (http://users.tpg.com.au/j_birch/plugins/superfish)

    // Add Superfish to all Nice menus with some basic options.
    (function ($) {
    $(document).ready(function() {
    // Apply a generic hover class.
    hoverClass: 'over',
    // Disable generation of arrow mark-up.
    autoArrows: false,
    // Disable drop shadows.
    dropShadows: false,
    // Mouse delay.
    delay: Drupal.settings.nice_menus_options.delay,
    // Animation speed.
    speed: Drupal.settings.nice_menus_options.speed
    // Add in Brandon Aaron’s bgIframe plugin for IE select issues.
    // http://plugins.jquery.com/node/46/release
    $('ul.nice-menu ul').css('display', 'none');

  2. Hi Chris,

    Even if you put it at the very top it should work.


  3. Programmer-

    Unfortunately, I was dealing with something a little more complicated. Nice Menu was getting hidden behind a SlideShow in the header, but I ended up fixing it by providing the same zIndex 1000 through the master.css file. Thank you for putting me on the right path!

  4. Chris,

    I am glad to be of some help.


  5. This worked for me. I had to place it at the bottom of the nice-menu.js to make it work though.

    Thanks man.

  6. Dear Frodopwns,
    Thank you for your feedback. It is much appreciated.


  7. Your help is very much appreciated. I was at lost here, when my nice menu flyout was hidden behind my content.

  8. Dear Diana,

    I am glad my experience was of some help to you.

    Dinesh Agarwal

  9. Nice! Would you like to present this at one of the upcoming LA Drupal meetups? drupal