简体   繁体   English

CSS / javascript悬停无法在Chrome中正确显示

[英]CSS/javascript hover does not display correctly in chrome

I am building a site that has an image map menu with a popup box that is supposed to pop at the mouse when the mouse is hovering over a particular area. 我正在构建一个站点,该站点的图像地图菜单带有一个弹出框,当鼠标悬停在特定区域上时,该弹出框应该会弹出鼠标。 It works great in firefox and IE but when I load the page in chrome the boxes appear as if the page were not scrolled. 它在firefox和IE中很好用,但是当我在chrome中加载页面时,框看起来好像页面没有滚动。 it works fine if the page is scrolled all the way to the top, but as soon as the user scrolls down, the boxes are to high on the page. 如果将页面一直滚动到顶部,则效果很好,但是一旦用户向下滚动,这些框就会在页面上居高不下。

I am using a script i got from http://www.dhtmlgoodies.com/index.html?whichScript=bubble_tooltip www(dot)dramanotebook(dot)com/menu/ (i can only put one hyperlink in) 我正在使用从http://www.dhtmlgoodies.com/index.html?获得的脚本?whichScript = bubble_tooltip www(dot)dramanotebook(dot)com / menu /(我只能放入一个超链接)

Thanks in advance for Your help 在此先感谢您的帮助

Thats a bug in this script that also shows up on the example page. 多数民众赞成在这个脚本中的错误,也出现在示例页面上。 Maybe its enough to delete this line: 也许足以删除此行:

if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 

I was about to ask 'have you tried this in Safari?', since Chrome and Safari both use the webkit engine. 我要问的是“您在Safari中尝试过此功能吗?”,因为Chrome和Safari都使用了webkit引擎。

Take a look at the .js file. 看一下.js文件。

function showToolTip(e,text){
/* blah blah*/
var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; /**** THIS  ****/
var leftPos = e.clientX - 100;
/*etc.*/
}   

It has a fix applied specifically to Safari, using the userAgent string. 它具有一个使用userAgent字符串的修复程序,专门用于Safari。 Chrome sends 'Safari' in the user agent string, too, so it will apply that to Chrome also. Chrome也会在用户代理字符串中发送“ Safari”,因此也会将其应用于Chrome。 This is generally considered a poor practice. 通常认为这是一种不良做法。 In general, I'd say the scripts from dhtmlgoodies are very outdated. 总的来说,我会说dhtmlgoodies的脚本已经过时了。 Is this fix still needed for newer webkit renderers? 较新的Webkit渲染器仍需要此修复程序吗? Who knows. 谁知道。 You might try commenting it out and seeing if that fixes it. 您可以尝试将其注释掉,看看是否可以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM