CSS悬停:似乎不起作用
我通过这样做来设置导航栏:
<div id="globalheader">
<ul id="globalnav">
<li id="home"><a href="#">Home</a></li>
</ul>
</div>
请注意,我删除了更多项目,因为这会使这个示例太大。
现在,这是我的 CSS:
/* GLOBALHEADER */
#globalheader { width: 506px; height: 36.75px; margin: 18px auto; position: relative; z-index: 9998; }
#globalheader #globalnav { margin: 0; padding: 0; }
#globalheader #globalnav li { display: inline; }
#globalheader #globalnav li a { float: left; width: 101.2px; height: 0; padding-top: 36.75px; overflow: hidden; }
#globalheader #globalnav li a,
#globalheader #globalnav { background-image: url(navbar.png); background-repeat: no-repeat; }
/* BUTTONS */
#globalheader #globalnav li#home a { background-position: 0 0; }
/* OVER STATES */
#globalheader #globalnav li#home a:hover { background-position: 0 -37; }
/* PRESSED STATES */
#globalheader #globalnav li#home a:active { background-position: 0 -73.5px; }
现在,为了节省空间,我删除了更多项目(正如我之前所说的)。
问题是:按钮显示正常,并且处于活动状态。但是,hover
似乎根本不起作用。有什么想法吗?
I'm setting up a navigation bar by doing this:
<div id="globalheader">
<ul id="globalnav">
<li id="home"><a href="#">Home</a></li>
</ul>
</div>
Please note I stripped a lot more items because it would make this example too large.
Now, here's my CSS:
/* GLOBALHEADER */
#globalheader { width: 506px; height: 36.75px; margin: 18px auto; position: relative; z-index: 9998; }
#globalheader #globalnav { margin: 0; padding: 0; }
#globalheader #globalnav li { display: inline; }
#globalheader #globalnav li a { float: left; width: 101.2px; height: 0; padding-top: 36.75px; overflow: hidden; }
#globalheader #globalnav li a,
#globalheader #globalnav { background-image: url(navbar.png); background-repeat: no-repeat; }
/* BUTTONS */
#globalheader #globalnav li#home a { background-position: 0 0; }
/* OVER STATES */
#globalheader #globalnav li#home a:hover { background-position: 0 -37; }
/* PRESSED STATES */
#globalheader #globalnav li#home a:active { background-position: 0 -73.5px; }
Now, there are more items (as I said previously) that I took out just for space's sake.
Here's the problem: The buttons display fine, and also the active
state. However, hover
doesn't seem to work at all. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将 px 添加到您的位置:
Try adding px to your position: