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 731619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:02:51+00:00 2026-05-14T07:02:51+00:00

I have two div elements that are twins (i.e. their dimensions and contents are

  • 0

I have two div elements that are twins (i.e. their dimensions and contents are identical). I want to move of those div-s over another, so that their corners are at exactly the same coordinates. What I try to do is:

var offset = $('div#placeholder').offset();
$('div#overlay').css('position', 'absolute').css('left', offset.left + 'px').css('top', offset.top + 'px')

— but this causes the overlay to be exactly (or almost exactly, taking subpixel accuracy into account) 16px below the placeholder (below, i.e. overlay_top = placeholder_top + 16px).

I’m aware that offset() gives position relative to the document, and position: absolute sets position relative to body element, but compensating for body offset() doesn’t help much (I’m getting 8px offset, equal to margins):

offset.top -= $('body').offset().top;
offset.left -= $('body').offset().left;

Also, compensating for body margins (in case they were different that offset() didn’t help, as they were set to 8px).

Does somebody know what I’m doing wrong here?

UPDATE: Take a look at here – I’m getting the same result in FireFox 3.6.3 and Opera 10.10.

  • 1 1 Answer
  • 1 View
  • 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-14T07:02:52+00:00Added an answer on May 14, 2026 at 7:02 am

    I’m suspicious that you have some CSS rule being applied based on a class/name/element type in the stylesheet. I suggest that you try setting margin/padding on the element to 0 via javascript. You might also want to use WebDeveloper or FireBug and inspect the computed styles on the element after repositioning to see what styles are being applied and from where.

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

Sidebar

Related Questions

I have two <div> elements that I want to position side by side like
I have two absolutely positioned div elements that overlap. Both have set z-index values
I have two DIV elements on a webpage. I want to remove inner html
I have a set of HTML reports that each contain two DIV elements with
I have two different div elements on two different webpages that use two different
I have a situation that i have a hidden div with two input elements
I have two div elements that are hidden on $(document).ready(function(){} and they are supposed
I have two div elements, one is the left panel, that is hidden, and
I have two div elements inside another. At times, from user interactivity, these two
I have two div -elements, the top one has the height of 40% and

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.