简体   繁体   中英

CSS menu looks good in FF/Chrome/Safari but not IE

I am using a CMS to build a site and I have some troubles with the menu. As topic says it's not perfect in IE. In the other browsers I hover over a menu item and a sub menu to that item is shown, when I hover over an item in the sub menu the item gets highlighted with a blue background. In IE however, only the first sub menu item gets highlighted when I hover over it but not when I hover over the others. As shown in my HTML below, if I hover over products-> Applications the background remains gray but if I hover over the first item (Online Services) the background turns blue.

The main menu items has an image as background and another image when I hover over it or it is active, the sub menus has a gray background and a blue one when I hover over the items.

HTML

<div id="header">

    <ul id="menuElem">

        <li class="home2"><a href="Home.aspx" >Home</a></li>
        <li class="products"><a href="Products.aspx" >Products</a>
            <ul>
                <li><a href="Products/Online-Services.aspx" >Online Services</a></li>
                <li><a href="Products/Applications.aspx" >Applications</a></li>
            </ul>
        </li>
        <li class="about"><a href="About.aspx" >About Us</a>
            <ul>
                <li><a href="Blog.aspx" >Blog</a></li>
                <li><a href="About/News.aspx" >News</a></li>
                <li><a href="About/Events.aspx" >Events</a></li>
            </ul>
        </li>
    </ul>

</div>

CSS for the menu sub items

#header li ul{
    background: rgb(211,211,211);
        display:none;
        height:auto;
    filter:alpha(opacity=95);
    opacity:0.95;
        position:absolute;
        width:161px;
    z-index:200;
    margin-left: 9px;
}

#header li li {
    display:block;
        float:none;
    padding: 0px;
    width:161px;
    margin-left: 0px;
    border-bottom: 1px solid;
    border-color: #fff;
}

#header li:hover ul{
        display:block;
}   

#header li ul li a {background-image: none; 
            color:#000;
            text-indent: 0px;
                    width: 161px; 
            padding-left: 5px;
}

#header li ul li a:hover {background-image: none;   
            background: rgb(26,66,126); 
            color:#fff; 
}

CSS for the main menu

#header ul {
    display:block;
    overflow:hidden;
    float:right;
    width:625px;
    height:38px;
    margin-top: 0px;
}

#header ul li {
    display:block;
    overflow:hidden;
    float:left;
    margin-left:2px;
}


menuhome a {
    display:block;
    overflow:hidden;
    background:url(images/nav_home.png) no-repeat;
    width:69px;
    height:38px;
    text-indent:-900px;
}

.menuhome2 a {
    display:block;
    overflow:hidden;
    background:url(images/nav_homeH.png) no-repeat;
    width:69px;
    height:38px;
    text-indent:-900px;
}

.menuhome a:hover, .menuhome a:active {
    background:url(images/nav_homeH.png) no-repeat;
}

.menuabout a {
    display:block;
    overflow:hidden;
    background:url(images/nav_about.png) no-repeat;
    width:88px;
    height:38px;
    text-indent:-900px;
}

.menuabout2 a {
    display:block;
    overflow:hidden;
    background:url(images/nav_aboutH.png) no-repeat;
    width:88px;
    height:38px;
    text-indent:-900px;
}

.menuabout a:hover, .menuabout a:active {
    background:url(images/nav_aboutH.png) no-repeat;
}


.menuproducts a {
    display:block;
    overflow:hidden;
    background:url(images/nav_products.png) no-repeat;
    width:87px;
    height:38px;
    text-indent:-900px;
}

.menuproducts2 a {
    display:block;
    overflow:hidden;
    background:url(images/nav_productsH.png) no-repeat;
    width:87px;
    height:38px;
    text-indent:-900px;
}

.menuproducts a:hover, .menuproducts a:active {
    background:url(images/nav_productsH.png) no-repeat;
}

Usually I just gooogle css horizontal menu and create one in the tools out there online and then copy and paste it but with this CMS (built on asp.net and uses a masterpage) I have to assign a class name in a menu for each menu item.

How do I fix this for IE?

Thanks in advance.

For the NOT IE CSS, you can use conditional comments, check out this article:

Conditional Comments .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM