gpt4 book ai didi

CSS Sprite 背景不移动

转载 作者:行者123 更新时间:2023-11-28 14:20:25 26 4
gpt4 key购买 nike

我对本应相当简单的 CSS Sprite 代码感到越来越沮丧。我一直在做一个县城 map ,当鼠标悬停在比县城名称大一点的链接框上时,县城名称会放大。

这是我的两个县的 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;}

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

最佳答案

删除背景:url(./LINKS/counties_hover_map.png) 不重复;来自##县,

改为将该行添加到#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;}

关于CSS Sprite 背景不移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8542747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com