Grow your CSS skills. Land your dream job.

Navigation hover issue in IE

  • # May 22, 2013 at 3:50 am

    I am having issues with a CSS navigation in IE. The navigation has top level links with drop down sub-menu’s on hover. The issue is that in IE when one moves off the top level link in an attempt to select one of the options from the drop down sub-menu, the sub menu disappears.

    The navigation displays fine in Firefox, Safari and Chrome but the issue occurs when using IE.

    I have used this exact navigation elsewhere (just without the extra padding between the main and sub links) and have tried a number of fixes but nothing seems to have worked. I am not sure if it has something to do with the header image which the navigation is placed on top of as when I remove this, the issue resolves in IE. BUT obviously I need both to work.

    Any help would be greatly appreciated.

    HTML code is:

    Main image

    CSS is:

    #header {
    width: 960px;
    height: 222px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    }

    .headertext {
    margin: -200px 0 0 650px;
    font-family: “Myriad Pro”, sans-serif;
    font-size: 0.9em;
    color: #ffffff;
    position: relative;
    z-index: 2;
    }

    .headertext ul{
    padding: 0px 0 0 30px;
    list-style-type: none;
    }

    .headertext li{
    padding: 0 10px 0 0;
    display: inline;
    font-family: “Myriad Pro”, Sans-serif;
    font-size: 0.8em;
    text-transform: uppercase;
    }

    .headertext li a{
    color: #ffffff;
    text-decoration: none;
    }

    .headertext li a:hover{
    color: #cccc99;
    }

    /* Main Image */

    #mainimage{
    width: 960px;
    height: 319px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 80px;
    }

    /* Nav Menu */

    #nav {
    width: 575px;
    margin: -350px 0 0 330px;
    position: absolute;
    z-index: 3;
    }

    ul#navmenu-h {
    height: 40px;
    list-style-type: none;
    padding: 0 0 0 0;
    margin: 0px;
    }

    ul#navmenu-h li {
    float: left;
    list-style: none;
    margin: 0;
    padding: 0 0 0 0;
    position: relative;
    }

    ul#navmenu-h ul {
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute; top: 25px; left: 0px;
    }

    ul#navmenu-h ul:after /*From IE 7 lack of compliance*/{
    clear: both;
    font-size: 1.5em;
    height: 0;
    margin: 0;
    padding: 0;
    visibility: hidden;
    }

    ul#navmenu-h ul li {
    display: block !important;
    display: inline; /*For IE*/
    float: left; /*For IE 7 lack of compliance*/
    width: 150px;
    }

    /* Root Menu */
    ul#navmenu-h a {
    color:#ffffff;
    background-color:inherit;
    display: block;
    float: none !important; /*For Opera*/
    float: left; /*For IE*/
    font-family: Times New Roman;
    font-size: 0.9em;
    line-height: 30px;
    height: auto !important;
    height: 1%; /*For IE*/
    text-decoration: none;
    text-transform: uppercase;
    padding: 0px 20px 0 20px;
    border-left: 1px solid #FFF;
    }

    /* Root Menu Hover Persistence */
    ul#navmenu-h a:hover,
    ul#navmenu-h li:hover a,
    ul#navmenu-h li.iehover a {
    background: transparent;
    color: #cccc99;
    }

    ul#navmenu-h ul li a.first {
    border-top: 1px solid #FFF !important;
    }

    /* 2ND MENU
    ======================================================================*/
    ul#navmenu-h li ul {
    border: none;
    background: #333333;
    color: #fff;
    margin: 17px 0 0 0;
    width: 7.8em;
    }

    ul#navmenu-h li:hover li a,
    ul#navmenu-h li.iehover li a {
    background: #333333;
    width: 60px;
    border: none;
    color: #fff;
    float: none;
    font-weight: normal;
    font-size: 0.70em;
    text-transform: uppercase;
    }

    /* 2nd Menu Hover Persistence */
    ul#navmenu-h li:hover li a:hover,
    ul#navmenu-h li:hover li:hover a,
    ul#navmenu-h li.iehover li a:hover,
    ul#navmenu-h li.iehover li.iehover a {
    background: #333333;
    color: #cccc99;
    }

    /* Do Not Move
    ======================================================================*/
    ul#navmenu-h li:hover ul ul,
    ul#navmenu-h li:hover ul ul ul,
    ul#navmenu-h li.iehover ul ul,
    ul#navmenu-h li.iehover ul ul ul {
    display: block;
    }

    ul#navmenu-h li:hover ul,
    ul#navmenu-h ul li:hover ul,
    ul#navmenu-h ul ul li:hover ul,
    ul#navmenu-h li.iehover ul,
    ul#navmenu-h ul li.iehover ul,
    ul#navmenu-h ul ul li.iehover ul {
    display: block;
    }

    Thanks in advance!

    # May 22, 2013 at 4:07 am

    Hi there!

    First, it might be a good idea to [create a Codepen](http://codepen.io/) with the code to make it easier to read.

    Second… From a usability perspective I would strongly advice against using hover as the trigger, both due to the problem you’re having right now, due to a general accessibility issue with devices without a hover (IE: touch-based ones), and also because my experience is that it can lead to issues with screenreading devices.

    Outside of that I unfortunately don’t have anything useful with your actual problem.

    # May 22, 2013 at 4:23 am

    Thanks Melindrea :-)

    # June 26, 2013 at 11:06 pm

    Nic, could you post how you solved this? I have the same issue and would like to fix it. Thanks!

    # July 10, 2013 at 2:25 pm

    ethayer594, the problem was with the “top” positioning in the following CSS:

    #nav ul ul {
    background: #333333;
    border-radius: 0px;
    padding: 0;
    position: absolute;
    top: 105%;
    }

    This created a “disconnection” between the parent and subnav child. I removed it and added padding instead and it solved the issue on my side. I hope this is helpful to you.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".