2011-12-17 95 views
0

我已经越来越沮丧了,应该是相当简单的CSS sprite代码。我一直在制作县级地图,当鼠标悬停在比县名大一点的链接框上时,会放大县名。CSS sprite背景不会移动

下面是两个县(有我的原代码几个县)我的HTML代码...

<ul id="counties"> 

<li id="russell"><a href="index.html">Russell</a></li> 
<li id="smyth"><a href="index.html">Smyth</a></li> 

</ul> 

...这里是我的CSS代码...

#counties { 
background: url(./LINKS/counties_hover_map.png) no-repeat; 
width: 750px; 
height: 648px; 
position: relative; 
} 
#counties li {list-style: none; display: block; position: absolute;} 
#counties a {display: block; text-indent: -9999px; text-decoration: none;} 

#russell {left: 244px; top: 112px; width: 161px; height: 56px;} 
#russell a {height: 56px; border: none; outline: none;} 
#russell a:hover{background-position: 0px -680px;} 

#smyth {left: 510px; top: 164px; width: 144px; height: 56px;} 
#smyth a {height: 56px; border: none; outline: none;} 
#smyth a:hover {background-position: 0px -784px;} 

...任何见解将不胜感激。 谢谢。

+0

你没有为#russell或#smith所以没有什么移动定义的背景。 – Scott 2011-12-17 05:26:30

回答

0

删除 background:url(./ LINKS/counties_hover_map.png)no-repeat;来自##县的 ,

将该行添加到#counties a代替。

,使其成为:

#counties { 
    width: 750px; 
    height: 648px; 
    position: relative; 
    } 
    #counties li {list-style: none; display: block; position: absolute;} 
    #counties a { 
    display: block; text-indent: -9999px; text-decoration: none; 
background: url(./LINKS/counties_hover_map.png) no-repeat; 
} 

    #russell {left: 244px; top: 112px; width: 161px; height: 56px;} 
    #russell a {height: 56px; border: none; outline: none;} 
    #russell a:hover{background-position: 0px -680px;} 

    #smyth {left: 510px; top: 164px; width: 144px; height: 56px;} 
    #smyth a {height: 56px; border: none; outline: none;} 
    #smyth a:hover {background-position: 0px -784px;}