CSS sprite 不只粘在主导航上?
请参阅 http://bldd.nl/prototypes/megamenu/test23.php
我是坚持这一点,如果您滚动子菜单导航,您会看到相应的主菜单滚动精灵吗?
我该如何解决这个问题并优化CSS?
See http://bldd.nl/prototypes/megamenu/test23.php
I am stuck with this, if you rollover the submenu navigation you see the corresponding mainmenu rollover sprite?
How can i fix this and optimize the css?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 CSS 使用后代选择器:
#jobs-news a:hover
。这将匹配
#jobs-news
内的任何a:hover
,即使它实际上位于其子级之一中。最简单的解决方案是为根
a
元素提供自己的类(例如),然后更改将悬停选择器设置为
#jobs-news a.MainLink:hover
。这样,它就不会匹配子项,因为它们没有
MainLink
类。如果您不需要支持 IE6,您还可以使用子选择器:
#jobs-news > a:悬停
Your CSS uses a descendant selector:
#jobs-news a:hover
.This will match any
a:hover
inside of#jobs-news
, even if it's actually in one of its children.The simplest solution would be to give the root
a
elements their own class (eg,<a class="MainLink" href="#">
), then change the hover selectors to#jobs-news a.MainLink:hover
.This way, it wouldn't match the subitems, since they wouldn't have the
MainLink
class.If you don't need to support IE6, you could also use a child selector:
#jobs-news > a:hover