2011-12-17 96 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;}