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

  • Home
  • SEARCH
  • 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 8827289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:20:16+00:00 2026-06-14T07:20:16+00:00

How do I get the position of a Div relatively to its parent Div?

  • 0

How do I get the position of a Div relatively to its parent Div? Using .position() and .offset() always gives me its position to the document.


HTML:

<div id="frame">
   <div id="inner"></div>
</div>

CSS:

Let’s assume frame is centered with margin: auto; and width: 1024px.

inner has left: 300px;, top: 200px and position: relative;.

What I want:

A nice function for getting inners‘s position data 300 and 200 (e.g. without px when using .css('left') etc.

Is there anything?

  • 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-06-14T07:20:18+00:00Added an answer on June 14, 2026 at 7:20 am

    If you give the parent a “position” of “relative”, then using .position() should be its position inside of the parent.

    Using .offset actually should always give you its position based off the document, while using .position gives you its “position” based off its first parent whose “position” is not “static” (default).

    Here’s examples:

    http://jsfiddle.net/Z2VNx/

    http://jsfiddle.net/Z2VNx/1/

    The first example uses <br /> to add space at the top of the container, while the second example uses padding-top to add space at the top of the container. Both return a value greater than 0 for the child’s top position.

    The only problem is that position does not account for the child’s margins, padding, and borders when calculating its position. This is because all of those are part of the element, so even though you may not visually see them, they wouldn’t be included in the element’s position calculation. So of course, depending on exactly what part of the element you want to see its position of, you need to add that to the result of .position. Some people want the “position” to return to top-left position of the border, which would mean adding the margin. Something like this:

    http://jsfiddle.net/Z2VNx/2/

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

Sidebar

Related Questions

I can't seem to get a div to absolutely position within its parent using
I want to get the position of a an element in its parent. For
I need to get position of element relative to its parent. position() is suppose
I have a div that is position: absolute and it contains items that get
How can I continuously get the position of the mouse whilst its button is
I need to get a position of a DIV relative to the body or
Basically, I want an outer DIV's height to be dictated by its inner DIVs
I am using an old CSS trick to get a semi-transparent background for some
Is it possible to get position inside the OpenLayers container from a lat/long point?
I am trying to get position inside a fling for a listview. No matter

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.