CSS Sprites——它们都可以工作,但只有一个

发布于 2024-11-30 10:22:13 字数 2870 浏览 1 评论 0原文

http://kilgourschameleons.com/new/test/index.asp

我遇到过使用CSS和精灵的一个非常奇怪的问题。如果您转到上面的链接,您将看到所有导航翻转都有效“主页”。我对所有按钮使用了相同的代码,并尝试复制有效的按钮并仅替换翻转的名称,使用“asdf”之类的名称作为名称,以防“home”被保留,等等。这毫无意义。

<div>
    <img src="images/spacer.gif" width=960 height=104 border=0>
    </div>
    <center>
    <ul id="navigation">
    <li><a href="index.asp" class="home active"></a></li>
    <li><a href="gallery.asp" class="gallery"></a></li>
    <li><a href="care.asp" class="care"></a></li>
    <li><a href="products.asp" class="products"></a></li>
    <li><a href="sires.asp" class="sires"></a></li>
    <li><a href="faq.asp" class="faq"></a></li>
    <li><a href="about.asp" class="about"></a></li>
    </ul>
    </center>
    <div>
    <img src="images/spacer.gif" width=960 height=37 border=0>
    </div>

这是CSS...

#navigation {
    position:relative;
    top:0px;
    width:960px;
    height=55px;
    text-align:center;
    margin-left: 0 auto;
    margin-right: 0 auto;
    margin:0;
    z-index:1000;
}
#navigation li {
    float: left;
}
#navigation li a {
    background: url("../images/navigation_bg.png") no-repeat scroll left top transparent;
    display: block;
    height: 55px;
}
#navigation li a.home {
    background-position: 0px 0px;
    width: 148px;
}
#navigation li a.gallery {
    background-position: -148px 0px;
    width: 109px;
}
#navigation li a.care {
    background-position: -257px 0px;
    width: 84px;
}
#navigation li a.products {
    background-position: -341px 0px;
    width: 115px;
}
#navigation li a.sires {
    background-position: -456px 0px;
    width: 79px;
}
#navigation li a.faq {
    background-position: -535px 0px;
    width: 80px;
}
#navigation li a.about {
    background-position: -615px 0px;
    width: 120px;
}

}
#navigation li a.home:hover, #navigation li a.home.active {
    background-position: 0px -55px;
}
#navigation li a.gallery:hover, #navigation li a.gallery.active {
    background-position: -148px -55px;
}
#navigation li a.care:hover, #navigation li a.care.active {
    background-position: -257px -55px;
}
#navigation li a.products:hover, #navigation li a.products.active {
    background-position: -341px -55px;
}
#navigation li a.sires:hover, #navigation li a.sires.active {
    background-position: -456px -55px;
}
#navigation li a.faq:hover, #navigation li a.faq.active {
    background-position: -535px -55px;
}
#navigation li a.about:hover, #navigation li a.about.active {
    background-position: -615px -55px;
}

http://kilgourschameleons.com/new/test/index.asp

I have come across a very strange problem using css and sprites. If you go to the link above you will see all the navigation rollovers work but "home". I have used the same code for all the buttons and tried copying the ones that work and just replacing the name of the rollover, using things like "asdf" as the name in case "home" was reserved, etc. This makes NO SENSE.

<div>
    <img src="images/spacer.gif" width=960 height=104 border=0>
    </div>
    <center>
    <ul id="navigation">
    <li><a href="index.asp" class="home active"></a></li>
    <li><a href="gallery.asp" class="gallery"></a></li>
    <li><a href="care.asp" class="care"></a></li>
    <li><a href="products.asp" class="products"></a></li>
    <li><a href="sires.asp" class="sires"></a></li>
    <li><a href="faq.asp" class="faq"></a></li>
    <li><a href="about.asp" class="about"></a></li>
    </ul>
    </center>
    <div>
    <img src="images/spacer.gif" width=960 height=37 border=0>
    </div>

This is the css...

#navigation {
    position:relative;
    top:0px;
    width:960px;
    height=55px;
    text-align:center;
    margin-left: 0 auto;
    margin-right: 0 auto;
    margin:0;
    z-index:1000;
}
#navigation li {
    float: left;
}
#navigation li a {
    background: url("../images/navigation_bg.png") no-repeat scroll left top transparent;
    display: block;
    height: 55px;
}
#navigation li a.home {
    background-position: 0px 0px;
    width: 148px;
}
#navigation li a.gallery {
    background-position: -148px 0px;
    width: 109px;
}
#navigation li a.care {
    background-position: -257px 0px;
    width: 84px;
}
#navigation li a.products {
    background-position: -341px 0px;
    width: 115px;
}
#navigation li a.sires {
    background-position: -456px 0px;
    width: 79px;
}
#navigation li a.faq {
    background-position: -535px 0px;
    width: 80px;
}
#navigation li a.about {
    background-position: -615px 0px;
    width: 120px;
}

}
#navigation li a.home:hover, #navigation li a.home.active {
    background-position: 0px -55px;
}
#navigation li a.gallery:hover, #navigation li a.gallery.active {
    background-position: -148px -55px;
}
#navigation li a.care:hover, #navigation li a.care.active {
    background-position: -257px -55px;
}
#navigation li a.products:hover, #navigation li a.products.active {
    background-position: -341px -55px;
}
#navigation li a.sires:hover, #navigation li a.sires.active {
    background-position: -456px -55px;
}
#navigation li a.faq:hover, #navigation li a.faq.active {
    background-position: -535px -55px;
}
#navigation li a.about:hover, #navigation li a.about.active {
    background-position: -615px -55px;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一梦浮鱼 2024-12-07 10:22:13

如果去掉 css 文件中多余的 } 会发生什么?看起来会起作用。

What happens if you get rid of the extra } in your css file? Looks like it'll work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文