我的CSS代码在Firefox中工作,但在Chrome中无效

时间:2013-05-25 10:00:48

标签: html css menu

我设计了一个magento菜单。我的菜单在firefox中工作正常。当我将鼠标悬停在firefox的菜单上时效果很好,但不会显示在chrome中悬停的效果。我的悬停风格是这样的:

#nav {
 width:965px; 
 margin: 0 191px -16px;
 font-size:10px;
 position: relative;
 z-index: 10; 
margin:auto;
 }

/* All Levels */ /* Style consistent throughout all nav levels */
#nav li { position:relative; text-align:left; }
#nav li.active{display:block;background-color: #632755;
    margin-top: 1px;}
    #nav li:hover{display:block;background-color:#ddaacc;margin-top:1px;}

#nav li.over { z-index:998; }
#nav a { }
#nav a,
#nav a:hover {/* background: url("../images/bg_nav.png");*/ display:block; text-decoration:none; /*text-transform:uppercase;*/ }
#nav span { display:block; cursor:pointer; white-space:nowrap; }
#nav li ul span {white-space:normal; }
#nav ul li.parent a { }
#nav ul li.parent li a { }

/* 0 Level */
#nav li { float:left; }
#nav li.active a { display:block;}
#nav a { float:left; padding:0 6px 0; }
#nav li.over > a,
#nav a:hover { }
#nav a.level-top { line-height:51px; font-size:17px;}
#nav li.over a.level-top { }

/* 1st Level */
#nav ul li,
#nav ul li.active { float:none; margin:0; padding: 0 12px;color:red;}
#nav ul li.last {  }

#nav ul a,
#nav ul a:hover {float:none; padding:0; line-height:1.3em;}
#nav ul li a { font-weight:normal !important; }
#nav ul li.over > a,
#nav ul a:hover { text-decoration:underline; }

/* 2nd Level */
#nav ul,
#nav div { position:absolute; width:15em; top:44px; left:-10000px; padding: 5px 0 0;}
#nav div ul { position:static; width:auto; border:none; }

/* 3rd+ Level */
#nav ul ul,
#nav ul div { top:-5px; }

#nav ul li a { }
#nav ul li a:hover {  }
#nav ul li a,
#nav ul li a:hover { background: url(../images/bkg_nav1.png) 0 100% repeat-x; }
#nav ul li.last > a { background:none; }
#nav ul span,
#nav ul li.last li span { padding:6px 0 5px; }

/* Show menu */
#nav li ul.shown-sub,
#nav li div.shown-sub { left:0; z-index:999; }
#nav li .shown-sub ul.shown-sub,
#nav li .shown-sub li div.shown-sub { left:15em; }

我的html是这样的:

<div class="nav-container">
<ul id="nav">
    <!--azz-J-->
    <a href="http://www.smartintellectual.com/" class="">
    <img src="http://www.smartintellectual.com/skin/frontend/em0012/default/images/flags/home.png"></a>
    <!--azz-J End-->
    <li class="level0 nav-1 first level-top parent"><a class="level-top" href="http://www.smartintellectual.com/lingerie.html"><span>Lingerie</span></a>
    <ul class="level0">
        <li class="level1 nav-1-1 first"><a href="http://www.smartintellectual.com/lingerie/lingerie-sets.html"><span>Lingerie Sets</span></a></li>
        <li class="level1 nav-1-2"><a href="http://www.smartintellectual.com/lingerie/basque-and-bustiers.html"><span>Basque and Bustiers</span></a></li>
        <li class="level1 nav-1-3"><a href="http://www.smartintellectual.com/lingerie/teddies.html"><span>Teddies</span></a></li>
        <li class="level1 nav-1-4"><a href="http://www.smartintellectual.com/lingerie/leather-lingerie.html"><span>Leather Lingerie</span></a></li>
        <li class="level1 nav-1-5"><a href="http://www.smartintellectual.com/lingerie/accessories.html"><span>Accessories</span></a></li>
        <li class="level1 nav-1-6"><a href="http://www.smartintellectual.com/lingerie/shoes.html"><span>Shoes</span></a></li>
        <li class="level1 nav-1-7 last"><a href="http://www.smartintellectual.com/lingerie/nipple-pasties.html"><span>Nipple Pasties </span></a></li>
    </ul>
    </li>
    <li class="level0 nav-2 level-top parent"><a class="level-top" href="http://www.smartintellectual.com/nightwear.html"><span>Nightwear</span></a>
    <ul class="level0">
        <li class="level1 nav-2-1 first"><a href="http://www.smartintellectual.com/nightwear/babydolls.html"><span>Babydolls</span></a></li>
        <li class="level1 nav-2-2"><a href="http://www.smartintellectual.com/nightwear/chemise.html"><span>Chemise</span></a></li>
        <li class="level1 nav-2-3"><a href="http://www.smartintellectual.com/nightwear/gowns-robes.html"><span>Gowns &amp; Robes</span></a></li>
        <li class="level1 nav-2-4 last"><a href="http://www.smartintellectual.com/nightwear/camisoles.html"><span>Camisoles</span></a></li>
    </ul>
    </li>
    <li class="level0 nav-3 level-top parent"><a class="level-top" href="http://www.smartintellectual.com/corsets.html"><span>Corsets</span></a>
    <ul class="level0">
        <li class="level1 nav-3-1 first"><a href="http://www.smartintellectual.com/corsets/leather-corsets.html" class=""><span>Leather Corsets</span></a></li>
        <li class="level1 nav-3-2"><a href="http://www.smartintellectual.com/corsets/overbust-corsets.html"><span>Overbust Corsets</span></a></li>
        <li class="level1 nav-3-3"><a href="http://www.smartintellectual.com/corsets/underbust-corsets.html"><span>Underbust Corsets</span></a></li>
        <li class="level1 nav-3-4 last"><a href="http://www.smartintellectual.com/corsets/steel-boned-corsets.html"><span>Steel Boned Corsets</span></a></li>
    </ul>
    </li>
    <li class="level0 nav-4 level-top parent"><a class="level-top" href="http://www.smartintellectual.com/bras.html"><span>Bras</span></a>
    <ul class="level0">
        <li class="level1 nav-4-1 first"><a href="http://www.smartintellectual.com/bras/dd-bras.html" class=""><span>DD+ Bras</span></a></li>
        <li class="level1 nav-4-2"><a href="http://www.smartintellectual.com/bras/strapless-bras.html" class=""><span>Strapless Bras</span></a></li>
        <li class="level1 nav-4-3"><a href="http://www.smartintellectual.com/bras/balconette-bras.html" class=""><span>Balconette Bras</span></a></li>
        <li class="level1 nav-4-4"><a href="http://www.smartintellectual.com/bras/plunge-bras.html"><span>Plunge Bras</span></a></li>
        <li class="level1 nav-4-5"><a href="http://www.smartintellectual.com/bras/push-up-bras.html"><span>Push UP Bras</span></a></li>
        <li class="level1 nav-4-6"><a href="http://www.smartintellectual.com/bras/shelf-bra.html"><span>Shelf Bra</span></a></li>
        <li class="level1 nav-4-7"><a href="http://www.smartintellectual.com/bras/soft-cup-bras.html"><span>Soft Cup Bras</span></a></li>
        <li class="level1 nav-4-8 last"><a href="http://www.smartintellectual.com/bras/t-shirt-bras.html"><span>T-Shirt Bras</span></a></li>
    </ul>
    </li>
    <li class="level0 nav-5 level-top parent"><a class="level-top" href="http://www.smartintellectual.com/bridal.html"><span>Bridal</span></a>
    <ul class="level0">
        <li class="level1 nav-5-1 first"><a href="http://www.smartintellectual.com/bridal/bridal-corsets.html"><span>Bridal Corsets</span></a></li>
        <li class="level1 nav-5-2"><a href="http://www.smartintellectual.com/bridal/bridal-basques-bustiers.html"><span>Bridal Basques &amp; Bustiers</span></a></li>
        <li class="level1 nav-5-3"><a href="http://www.smartintellectual.com/bridal/bridal-hosiery.html"><span>Bridal Hosiery</span></a></li>
        <li class="level1 nav-5-4 last"><a href="http://www.smartintellectual.com/bridal/bridal-thongs.html"><span>Bridal Thongs</span></a></li>
    </ul>
    </li>
    <li class="level0 nav-6 level-top parent"><a class="level-top" href="http://www.smartintellectual.com/knickers.html"><span>Knickers</span></a>
    <ul class="level0">
        <li class="level1 nav-6-1 first"><a href="http://www.smartintellectual.com/knickers/micro-g-strings.html"><span>Micro G-Strings</span></a></li>
        <li class="level1 nav-6-2"><a href="http://www.smartintellectual.com/knickers/thongs.html"><span>Thongs</span></a></li>
        <li class="level1 nav-6-3"><a href="http://www.smartintellectual.com/knickers/briefs.html"><span>Briefs</span></a></li>
        <li class="level1 nav-6-4"><a href="http://www.smartintellectual.com/knickers/g-strings.html"><span>G Strings</span></a></li>
        <li class="level1 nav-6-5 last"><a href="http://www.smartintellectual.com/knickers/shorts.html"><span>Shorts</span></a></li>
    </ul>
    </li>
    <li class="level0 nav-7 level-top parent"><a class="level-top" href="http://www.smartintellectual.com/hosiery.html"><span>Hosiery</span></a>
    <ul class="level0">
        <li class="level1 nav-7-1 first"><a href="http://www.smartintellectual.com/hosiery/bodystockings.html"><span>Bodystockings</span></a></li>
        <li class="level1 nav-7-2"><a href="http://www.smartintellectual.com/hosiery/garterbelts.html"><span>Garterbelts</span></a></li>
        <li class="level1 nav-7-3"><a href="http://www.smartintellectual.com/hosiery/stockings.html"><span>Stockings</span></a></li>
        <li class="level1 nav-7-4 last"><a href="http://www.smartintellectual.com/hosiery/pantyhose.html"><span>Pantyhose</span></a></li>
    </ul>
    </li>
    <li class="level0 nav-8 level-top"><a class="level-top" href="http://www.smartintellectual.com/costumes.html"><span>Costumes</span></a></li>
    <li class="level0 nav-9 level-top"><a class="level-top" href="http://www.smartintellectual.com/plus-size.html"><span>Plus size</span></a></li>
    <li class="level0 nav-10 level-top"><a class="level-top" href="http://www.smartintellectual.com/sale-shop.html"><span>Sale shop</span></a></li>
    <li class="level0 nav-11 last level-top"><a class="level-top" href="http://www.smartintellectual.com/valentines-lingerie.html"><span>Valentines Lingerie</span></a></li>
</ul>

2 个答案:

答案 0 :(得分:1)

问题在于此行的显示块

#nav li:hover{display:block;background-color:#ddaacc;margin-top:1px;}

删除它并且可以正常工作

见demo:

fiddle

答案 1 :(得分:0)

最好将悬停效果放在<a>上,而不是<li>

#nav li a:hover {background-color:#ddaacc;}