CSS 翻转精灵

发布于 2024-08-29 04:49:15 字数 251 浏览 5 评论 0原文

我以前使用过这种效果,一切正常(据我所知),但它就是不起作用。我错过了什么?

在这里摆弄

精灵在这里

谢谢。

I have used this effect before, everything is in order (As far as I see), but it's just not working. What have I missed?

Fiddle here

Sprite here

Thanks.

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

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

发布评论

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

评论(4

巨坚强 2024-09-05 04:49:15

由于您的精灵是水平排列的,因此您需要像这样偏移悬停状态:

element:hover {
background-position: -77px 0;
}

Since your sprite is arranged horizontally, you will want to offset the hover state like this:

element:hover {
background-position: -77px 0;
}
孤凫 2024-09-05 04:49:15

你的背景偏移似乎是错误的 - 而不是 0 77px (这是一个 y 偏移,沿着错误的轴),尝试 -77px 0。

Your background offset seems to be wrong - instead of 0 77px (which is a y-offset, along the wrong axis), try -77px 0.

以为你会在 2024-09-05 04:49:15

只需更改

background-position: 0 77px;

background-position: -77px 0;

just change

background-position: 0 77px;

to

background-position: -77px 0;
橘香 2024-09-05 04:49:15

嗯,你的背景位置是调整顶部起始位置而不是左侧起始位置?

Um, your background-position is adjusting the top starting position rather than the left starting position?

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