Answer the question
In order to leave comments, you need to log in
Relative positioning with jQuery?
Help position elements relative to each other, taking into account scrolling in different browsers.
Made an additional block when hovering the mouse. Here is a piece of code responsible for calculating the position of the new block on the page:
...<br/>
<br/>
var mytop = image.offset().top - (container.height() /2) + image.height()/2 + $(document).scrollTop();<br/>
var myleft = image.offset().left - (container.width() /2 ) + image.width()/2 + $(document).scrollLeft();<br/>
<br/>
if($.browser.msie){<br/>
mytop = image.offset().top - (container.height() /2) + image.height()/2;<br/>
myleft = image.offset().left - (container.width() /2 ) + image.width()/2;<br/>
}<br/>
<br/>
container.offset({top: mytop, left: myleft});<br/>
container.show();<br/>
<br/>
...<br/>
Answer the question
In order to leave comments, you need to log in
In jQuery, everything is fine, the interpretation of chrome has changed, now it does not compensate for scrolling.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question