鼠标悬停子菜单已损坏

时间:2010-08-25 13:00:09

标签: html css mouseover submenu

我有一个鼠标悬停子菜单在我的网站上运行得非常好(事实上它很好地在Chrome,IE 7& 8和FF中完全正常工作),但现在它已经破坏了某种程度,我看不到问题

这是CSS:

.MainMenu {
    width: 90% !important;
    min-width: 800px;
    height: 42px !important;
    padding: 0 0 0 10%;
    overflow: hidden;
    border-top: 1px solid #0054a6;
    border-bottom: 1px solid #0054a6;
    background: transparent url("Images/ServiceMenuBG.png");
    background-repeat: repeat-x;
}
.MainMenu ul {
    padding: 0;
    margin:0;
    list-style: none;
}
.MainMenu li {
    float: left;
    position: relative;
    height: 31px;
    width: 150px;
    padding: 11px 0 0 0;
    text-align: center;
    border-right: 1px solid #0054a6;
}
.MainMenuItem#First { border-left: 1px solid #0054a6; }
.MainMenuItem a {
    color: #ffffff;
    display: block;
    height: 31px;
    width: 150px;
    font-weight: bold;
    text-decoration: none;
}
.MainMenuItem:hover { background: transparent url("Images/ServiceMenuBG.png") repeat-x 0 -42px; }
.SubMenu {
    z-index: 500;
    display: none;
    width: 150px !important;
    position: absolute;
    top: 10px;
    left: 0;
    background-color: rgb(51,118,184);
}
.SubMenu li { padding: 0 0 2px 5px; height: 20px !important; width: 143px; }
.SubMenu li a {
    height: 20px !important;
    font-weight: normal;
    color: #ffffff;
    text-align: left;
    text-decoration: none;
}
.SubMenu li a:hover { text-decoration: underline; }
.MainMenu li.MainMenuItem>ul { top: auto; left: auto; }
.MainMenu li.MainMenuItem:hover ul { display: block; }'

这是HTML:

<div class="MainMenu">
    <ul>
        <li class="MainMenuItem" id="First"><a href="~/Default.aspx">Home</a></li>
        <li class="MainMenuItem"><a href="Pages/Philosophies.aspx">Philosophies</a></li>
        <li class="MainMenuItem"><a href="Pages/Services.aspx#top">Services</a>
            <ul class="SubMenu">
                <li id="TopItem"><a href="Pages/Services.aspx#shop">Shop Repair</a></li>
                <li><a href="Pages/Services.aspx#donations">Donations</a></li>
                <li><a href="Pages/Services.aspx#consulting">Consulting</a></li>
                <li id="BottomItem"><a href="Pages/Services.aspx#on-site">On-site Service</a></li>
            </ul>
        </li>
        <li class="MainMenuItem"><a href="Pages/Contracts.aspx">Contracts</a></li>
        <li class="MainMenuItem"><a href="Pages/AboutUs.aspx">About Us</a></li>
        <li class="MainMenuItem"><a href="Pages/ContactUs.aspx">Contact Us</a></li>
    </ul>
</div>

SubMenu不会在鼠标悬停时显示,或者如果我将其初始display属性设置为block。就好像它根本不存在于页面上一样。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

.MainMenu { overflow: hidden; }

隐藏了子菜单,因此请删除该行。 CSS中的第6行。

正如Sotiris所说

.MainMenuItem a { color: #ffffff; }

隐藏顶部菜单项(可能不在您的版本上,因为我看到您有背景图片)