Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6107173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:09:35+00:00 2026-05-23T14:09:35+00:00

I’ve created a test case, please check it out as it illustrates my issue:

  • 0

I’ve created a test case, please check it out as it illustrates my issue: http://jsfiddle.net/jAD2W/6/ (reduced example thanks to @patrick dw)

For completeness, this code has also been added to the bottom of this post.

Basically, whenever I get the offset of a span element or inline div element, the top value is larger than it should be.

When you mouse-over the image in the example, it should stay at that absolute position. Unfortunately, it appears to be moved down.

What is causing it to move down? Removing the span element solves the problem, which indicates that it is caused by the inline property of the span element. Unfortunately, I do need the entire thing to be contained by a span or an inline div element.

The code from jsFiddle (html, javascript, css):

<html>
<body>
    <div id='showArea'>
        <span id="containerElement1">
             <img src='http://twitpic.com/show/thumb/5lkmac.jpg' >
        </span>
    </div>
</body>
</html>


$('#containerElement1').mouseenter(function(e) {
    var offset = $(this).offset();
    $(this).css({
        'position': 'absolute',
        'top': offset.top,
        'left': offset.left
    });
});

img {
    width:250px;
    height:150px;
}
span {
    width:250px;
    height:150px;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:09:36+00:00Added an answer on May 23, 2026 at 2:09 pm

    I think the problem is that as soon as you give the elements “position: absolute”, you change a bunch of stuff about the layout. For starters, the <span> elements are just “position: static” and “display: inline”. Because they’re inline, the “top” value looks big because they’re set on a text baseline that’s at the bottom of their container. The container <div> is stretched around them, in other words, and the top is the top of the row of text (non-existent in your example, but that’s what the browser thinks).

    When you flip them to “position: absolute”, the meaning of those things changes.

    If you start things off with a CSS rule that gives the spans “display: inline-block”, then the behavior changes (though it’s still somewhat weird). (edit — ah, it’s the “text-align: center” that’s doing the horizontal movement. Once the first element is yanked out of the line, the other has to re-center itself.)

    Note that when you add the spans, giving them a height has no effect; they’re inline elements, not blocks.

    edit — I’ve thought about how to do this, but it’s a little tricky because it’s not clear what effect you want. The problem is that the rules of layout for the inline content will affect the images and cause odd behavior. That “text-align: center”, for example, will move things around as soon as you “pin” an image. Thus, with “inline-block”, when you move over an element it will freeze in place, but the other image will then be adjusted to obey that “text-align” rule, and thus overlap the pinned one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.