Safari 和 Chrome 中的 CSS 菜单问题。除非你速度非常快,否则子菜单会在悬停时消失!
当您将鼠标悬停在顶级链接上时,子菜单会按其应有的方式显示,但是当您将光标向下移动到子菜单上时,它有时会立即消失,有时会在第三个或第四个子菜单链接之后消失,具体取决于您的精确度或速度! 它在 firefox、ie7 和 ie8 中运行良好,并验证 css 和 xhtml 过渡。 请帮助我只是看不到问题所在。我确实尝试将 margin-top: -1px 添加到 sub li 和/或 sub ul 但无济于事。
任何想法都感激不尽。哦,我应该说我正在使用 Windows Vista、Safari 4.0.4,并且站点用户标记了该问题,他正在使用 Safari 3 和 Windows XP。
谢谢
Anni
html 代码:
<ul id="menu">
<li id="menu1" ><a href="http://www.theservicebusiness.com/" title="Home">Home</a></li>
<li id="menu15" class="active"><a href="/what-we-do.html" title="What we do">What we do</a><ul class="subm"><li class=" subli">
<a href="/what-is-lean-service.html" title="What is Lean Service">What is Lean Service</a>
</li>
<li class=" subli">
<a href="/performance-metrics.html" title="Performance Metrics">Performance Metrics</a>
</li>
<li class=" subli">
<a href="/service-network-lean.html" title="Designing the service network around Lean concepts">Service Network</a>
</li>
<li class=" subli">
<a href="/global-process.html" title="Global process">Global Process</a>
</li>
<li class=" subli">
<a href="/organisation.html" title="Organisation">Organisation</a>
</li>
<li class="last subli">
<a class="last" href="/technology-and-information.html" title="Technology and Information">Technology</a>
</li>
</ul></li>
<li id="menu72" ><a href="/how-we-do-it.html" title="How we do it">How we do it</a><ul class="subm"><li class=" subli">
<a href="/discovery.html" title="Discovery">Discovery</a>
</li>
<li class=" subli">
<a href="/gain-share.html" title="Gain Share">Gain Share</a>
</li>
<li class="last subli">
<a class="last" href="/smart-sourcing.html" title="Smart Sourcing">Smart Sourcing</a>
</li>
</ul></li>
<li id="menu54" ><a href="/clients.html" title="Clients">Clients</a><ul class="subm"><li class=" subli">
<a href="/testimonials.html" title="Testimonials">Testimonials</a>
</li>
<li class=" subli">
<a href="/defence.html" title="Defence industry case studies">Defence</a>
</li>
<li class=" subli">
<a href="/hi-tech.html" title="Hi-Tech">Hi-Tech</a>
</li>
<li class=" subli">
<a href="/Industrial.html" title="Industrial">Industrial</a>
</li>
<li class=" subli">
<a href="/telecom.html" title="Telecom">Telecom</a>
</li>
<li class=" subli">
<a href="/computing.html" title="Computing">Computing</a>
</li>
<li class=" subli">
<a href="/medical.html" title="Medical Sector">Medical</a>
</li>
<li class="last subli">
<a class="last" href="/rail.html" title="Rail">Rail</a>
</li>
</ul></li>
<li id="menu33" ><a href="/about-us.html" title="About us">About Us</a><ul class="subm"><li class=" subli">
<a href="/director-bios.html" title="Director Bios">Director Bios</a>
</li>
<li class=" subli">
<a href="/ethical-and-social-responsibility.html" title="Ethical and social responsibility">Social Responsibility</a>
</li>
<li class="last subli">
<a class="last" href="/jobs.html" title="Job opportunities">Job Opportunities</a>
</li>
</ul></li>
<li id="menu73" ><a href="/global-locations.html" title="Global Locations">Global Locations</a></li>
<li id="menu6" ><a href="/contact-us.html" title="Contact Us">Contact us</a></li>
<li id="menu2" class="last"><a href="/blog.html" title="Blog">Blog</a></li>
</ul>
和 css:
#head, #headint, #menu ul {z-index:100}
#head h1, #headint h1 {z-index:0}
#menu1 {z-index:99}
#menu15 {z-index:98}
#menu32 {z-index:97}
#menu33 {z-index:96}
#menu48 {z-index:95}
#menu6 {z-index:94}
#menu2 {z-index:93}
#menu49 {z-index:92}
#menu, #menu ul {padding: 0;margin: 0 auto; list-style: none; width: 940px; }
#menu a {display: block;border:0; }
#menu li { float: left;width: 100px; background:transparent ; margin-bottom:0; height: 50px;}
#menu li a {text-align: center; padding-top: 37px; font-size: 13px; font-weight: bold;color: #C3C3C3; background: url(../images/bg_nav-00-divider.png) no-repeat ; background-position: 0 bottom}
#menu li a:hover { color:#99ccff}
li#menu72 ul.subm, li#menu15 ul.subm, li#menu54 ul.subm, li#menu33 ul.subm { position:relative; width: 196px; left: -999em; background:transparent url('../images/bg_subnav.png') no-repeat scroll 0 bottom;text-align:left }
li#menu72 ul.subm li, li#menu15 ul.subm li, li#menu54 ul.subm li, li#menu33 ul.subm li { float:none; background:transparent; display:block; width:183px;text-align:left; height: 31px; }
li#menu72 ul.subm li a, li#menu15 ul.subm li a, li#menu54 ul.subm li a, li#menu33 ul.subm li a { padding:15px 0 0 35px; background: transparent url('../images/menbul.png') no-repeat 5px bottom; text-align:left}
li#menu72 ul.subm li.last a.last, li#menu15 ul.subm li.last a.last, li#menu54 ul.subm li.last a.last, li#menu33 ul.subm li.last a.last { padding:15px 0 25px 35px !important; background: transparent url('../images/menbul.png') no-repeat 5px 10px; }
li#menu72 ul.subm li.last, li#menu15 ul.subm li.last, li#menu54 ul.subm li.last, li#menu33 ul.subm li.last { height:56px}
#menu li:hover ul, #menu li.sfhover ul {left: auto ;}
li#menu1{ width:253px;}
li#menu1 a{ background: url('../images/logo.png') no-repeat 0px 0px; left: 0px; width: 253px; top: 5px; height: 50px;overflow: hidden; text-indent: -9999em; outline: none}
#menu:hover li {background-position: 0 0;}
li#menu49 a { color:#99ccff; font-weight:bold;font-size:13px}
li#menu49 a:hover { color:#C3C3C3; }
li#menu54{ width:90px;}
li#menu33{ width:90px;}
li#menu6{ width:90px;}
li#menu2{ width:56px;}
li#menu73{ width:130px;}
When you hover over the top level links, the submenu appears as it should, but when you move the cursor down over the sub menu, it disappears sometime immediately and sometimes after the 3rd or 4th submenu link depending on how precise or fast you are!
It works fine in firefox, ie7 and ie8 and validates for css and xhtml transitional.
Please help I just can't see the problem. I did try adding margin-top: -1px to the sub li and/or to the sub ul to no avail.
Any ideas at all gratefully received. Oh and I should say that I am using windows vista, safari 4.0.4 and that a site user flagged up the problem and he was using safari 3 and windows xp.
Thanks
Anni
html code:
<ul id="menu">
<li id="menu1" ><a href="http://www.theservicebusiness.com/" title="Home">Home</a></li>
<li id="menu15" class="active"><a href="/what-we-do.html" title="What we do">What we do</a><ul class="subm"><li class=" subli">
<a href="/what-is-lean-service.html" title="What is Lean Service">What is Lean Service</a>
</li>
<li class=" subli">
<a href="/performance-metrics.html" title="Performance Metrics">Performance Metrics</a>
</li>
<li class=" subli">
<a href="/service-network-lean.html" title="Designing the service network around Lean concepts">Service Network</a>
</li>
<li class=" subli">
<a href="/global-process.html" title="Global process">Global Process</a>
</li>
<li class=" subli">
<a href="/organisation.html" title="Organisation">Organisation</a>
</li>
<li class="last subli">
<a class="last" href="/technology-and-information.html" title="Technology and Information">Technology</a>
</li>
</ul></li>
<li id="menu72" ><a href="/how-we-do-it.html" title="How we do it">How we do it</a><ul class="subm"><li class=" subli">
<a href="/discovery.html" title="Discovery">Discovery</a>
</li>
<li class=" subli">
<a href="/gain-share.html" title="Gain Share">Gain Share</a>
</li>
<li class="last subli">
<a class="last" href="/smart-sourcing.html" title="Smart Sourcing">Smart Sourcing</a>
</li>
</ul></li>
<li id="menu54" ><a href="/clients.html" title="Clients">Clients</a><ul class="subm"><li class=" subli">
<a href="/testimonials.html" title="Testimonials">Testimonials</a>
</li>
<li class=" subli">
<a href="/defence.html" title="Defence industry case studies">Defence</a>
</li>
<li class=" subli">
<a href="/hi-tech.html" title="Hi-Tech">Hi-Tech</a>
</li>
<li class=" subli">
<a href="/Industrial.html" title="Industrial">Industrial</a>
</li>
<li class=" subli">
<a href="/telecom.html" title="Telecom">Telecom</a>
</li>
<li class=" subli">
<a href="/computing.html" title="Computing">Computing</a>
</li>
<li class=" subli">
<a href="/medical.html" title="Medical Sector">Medical</a>
</li>
<li class="last subli">
<a class="last" href="/rail.html" title="Rail">Rail</a>
</li>
</ul></li>
<li id="menu33" ><a href="/about-us.html" title="About us">About Us</a><ul class="subm"><li class=" subli">
<a href="/director-bios.html" title="Director Bios">Director Bios</a>
</li>
<li class=" subli">
<a href="/ethical-and-social-responsibility.html" title="Ethical and social responsibility">Social Responsibility</a>
</li>
<li class="last subli">
<a class="last" href="/jobs.html" title="Job opportunities">Job Opportunities</a>
</li>
</ul></li>
<li id="menu73" ><a href="/global-locations.html" title="Global Locations">Global Locations</a></li>
<li id="menu6" ><a href="/contact-us.html" title="Contact Us">Contact us</a></li>
<li id="menu2" class="last"><a href="/blog.html" title="Blog">Blog</a></li>
</ul>
and the css:
#head, #headint, #menu ul {z-index:100}
#head h1, #headint h1 {z-index:0}
#menu1 {z-index:99}
#menu15 {z-index:98}
#menu32 {z-index:97}
#menu33 {z-index:96}
#menu48 {z-index:95}
#menu6 {z-index:94}
#menu2 {z-index:93}
#menu49 {z-index:92}
#menu, #menu ul {padding: 0;margin: 0 auto; list-style: none; width: 940px; }
#menu a {display: block;border:0; }
#menu li { float: left;width: 100px; background:transparent ; margin-bottom:0; height: 50px;}
#menu li a {text-align: center; padding-top: 37px; font-size: 13px; font-weight: bold;color: #C3C3C3; background: url(../images/bg_nav-00-divider.png) no-repeat ; background-position: 0 bottom}
#menu li a:hover { color:#99ccff}
li#menu72 ul.subm, li#menu15 ul.subm, li#menu54 ul.subm, li#menu33 ul.subm { position:relative; width: 196px; left: -999em; background:transparent url('../images/bg_subnav.png') no-repeat scroll 0 bottom;text-align:left }
li#menu72 ul.subm li, li#menu15 ul.subm li, li#menu54 ul.subm li, li#menu33 ul.subm li { float:none; background:transparent; display:block; width:183px;text-align:left; height: 31px; }
li#menu72 ul.subm li a, li#menu15 ul.subm li a, li#menu54 ul.subm li a, li#menu33 ul.subm li a { padding:15px 0 0 35px; background: transparent url('../images/menbul.png') no-repeat 5px bottom; text-align:left}
li#menu72 ul.subm li.last a.last, li#menu15 ul.subm li.last a.last, li#menu54 ul.subm li.last a.last, li#menu33 ul.subm li.last a.last { padding:15px 0 25px 35px !important; background: transparent url('../images/menbul.png') no-repeat 5px 10px; }
li#menu72 ul.subm li.last, li#menu15 ul.subm li.last, li#menu54 ul.subm li.last, li#menu33 ul.subm li.last { height:56px}
#menu li:hover ul, #menu li.sfhover ul {left: auto ;}
li#menu1{ width:253px;}
li#menu1 a{ background: url('../images/logo.png') no-repeat 0px 0px; left: 0px; width: 253px; top: 5px; height: 50px;overflow: hidden; text-indent: -9999em; outline: none}
#menu:hover li {background-position: 0 0;}
li#menu49 a { color:#99ccff; font-weight:bold;font-size:13px}
li#menu49 a:hover { color:#C3C3C3; }
li#menu54{ width:90px;}
li#menu33{ width:90px;}
li#menu6{ width:90px;}
li#menu2{ width:56px;}
li#menu73{ width:130px;}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现问题...横幅与菜单重叠。使用您提供的代码我无法复制该问题。但在添加横幅和适当的 CSS 后,我发现它是重叠的。
经过多次尝试将整个事情向下移动(添加 5
的工作哈哈)。我找到了源代码,将此行margin-bottom: 0
更改为margin-bottom: 5px
I found the problem... the banner is overlapping the menu. With the code you provided I couldn't replicate the problem. But after adding the banner and appropriate CSS I found it was overlapping.
After many attempts at moving the whole thing down (adding 5
<br />
's worked LOL). I found the source, change this line,margin-bottom: 0
tomargin-bottom: 5px
我在复制这个问题时遇到了困难,但我想我有一些东西可以让你尝试。
看来您正在使用相对定位来隐藏和显示子菜单(从 -999em 移动到自动)。相反,我会尝试使用:
这样,元素就不会移动——它们被“卡”在适当的位置,只是被切换。
尝试一下,让我们知道它是如何工作的。祝你好运!
I had trouble replicating this issue, but I think I have something for you to try.
It seems that you're using relative positioning to hide and show the sub-menus (moving from -999em to auto). Instead, I would try using:
This way, the elements aren't moving around -- they're "stuck" in place, and just being toggled.
Give this a shot, and let us know how it works. Best of luck!
我也遇到了同样的问题,事实证明实际上是黄色工具提示造成的。如果最终用户的光标成功悬停在工具提示上,Safari 将结束悬停事件,因为它不会将工具提示视为其父 html 元素的一部分。作为修复,我实现了 jquery,当最终用户将鼠标悬停在导航中的 a 标记上时,从它们中删除标题属性。
希望这可以帮助其他人解决这个问题,因为我花了大约一个小时才弄清楚。
I had this same issue and it turns out it was actually the yellow tooltips that were the cause. If the end user's cursor manages to hover over a tooltip, safari will end the hover event b/c it doesn't see tooltips as part of their parent html element. As a fix I implemented jquery to remove the title attributes from the a tags in the navigation when the end user hovers over them.
Hope this helps everyone else with this issue as it took me about an hour to figure it out.