jQuery的位置()在safari和chrome中无法正常工作 [英] jquery position() not working correctly in safari and chrome

查看:125
本文介绍了jQuery的位置()在safari和chrome中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过这个问题曾经有过一两次,但从来没有一个答案适用于我的问题(据我所知)。
我点击一个链接时会出现一个工具提示。我根据链接的位置设置了工具提示的位置,类似于此:

I've seen this question posed once or twice before, but never with an answer that applies to my problem (as far as I know). I have a tooltip that appears when a link is clicked. I set the position of the tooltip based on the position of the link similar to this:

$('#tooltip').css('left', $(this).position().left);

这对FF,IE等非常有用,但在Chrome和Safari中,工具提示总是大约60像素左右比我想要的左边更远。我真的不喜欢编写浏览器特定的代码,所以有人有任何理由知道这会发生吗?
提前致谢。

This works great in FF, IE, etc., but in Chrome and Safari, the tooltip is always about 60 pixels or so further to the left than I want. I really don't like writing browser specific code, so is there any reason anyone knows that this would be happening? Thanks in advance.

更新:
我可以通过从链接中删除边距:0自动样式来解决此问题。 Soooo ......修正了它,但我仍然不知道为什么这是safari和chrome中的问题。

推荐答案

根据stackoverflow ettiquette,可以回答你自己的问题,所以...
我是能够通过从链接中删除边距:0自动样式来解决此问题。 Soooo ......修正了它,但我仍然不知道为什么这是safari和chrome中的问题。但是,至少它是固定的。

According to stackoverflow ettiquette, it's okay to answer you're own question, so... I was able to fix this problem by removing the margin:0 auto style from the link. Soooo...that fixed it, but I still have no idea WHY this was a problem in safari and chrome. But, still at least it's fixed.

这篇关于jQuery的位置()在safari和chrome中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆