jquery position() not working correctly in safari and chrome

前端 未结 4 914
借酒劲吻你
借酒劲吻你 2021-01-06 03:54

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 cli

4条回答
  •  囚心锁ツ
    2021-01-06 04:37

    Just had the same problem, and removing margin: 0 auto; wasn't an option (nor is it a solution :). This worked for my needs, since webkit reports the value we're looking for as the left margin (so long as the margin is > 0, otherwise it does report position().left!):

    iPosLeft = oEl.position().left + parseInt(oEl.css('marginLeft'));
    

提交回复
热议问题