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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:52:42+00:00 2026-05-29T15:52:42+00:00

I see top/left properties display difference with position absolute and position relative as it

  • 0

I see top/left properties display difference with position absolute and position relative as it should.

When I set margin-top on position:relative it positions correctly according to containing container. BUT when I set margin-top on position:absolute, I think it should be positioned according to BODY element but it is positioned same as position:relative which is relative to containing element (#container). And I have not set any element non-static as well.

Here is code with position:relative
http://jsfiddle.net/uFta4/

And here is with position:absolute
http://jsfiddle.net/uFta4/2/

Please note that #firstDiv is positioned at same location which is relative to #container.

Should it be relative to BODY element?

  • 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-29T15:52:44+00:00Added an answer on May 29, 2026 at 3:52 pm

    Its because there is difference between RP and AP elements in a sense that RP elements ‘collapse’ their margins while AP element doesn’t collapse their margin. That’s why you are seeing AP element at same position because its also counting BODY margin you gave in its tag.

    To make you understand better I have put couple of codes.
    Look at following variations and observe different behavior margin collapsing of RP and AP elements.
    RP

    1. RP element margin collapse http://jsfiddle.net/uFta4/6/
    2. AP element margins is added http://jsfiddle.net/uFta4/7/
    3. AP elements with -ve margin added (becomes -20px) http://jsfiddle.net/uFta4/9/
    4. RP elements with -ve margin collapse(doesn’t become -30px) http://jsfiddle.net/uFta4/10/

    I hope now it will be clear to you.

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

Sidebar

Related Questions

On my website, www.funpunks.com, in the top left of the page you'll see the
See http://www.gymandfitness.com.au , goto a general product and on the top left of the
When you run top and see all running processes, I've always wanted to know
near the top of the code i see things like, btn_dropdown._visible = false; mcMenuBkg._visible
I often use the top command to see what is taking up resources. Mostly
Off the top of my head, I don't see any reason why you couldn't
Please go to: http://jlecologia.com/page1c.html to see the problem The top box look fine but
I'm plotting on top of an image in Matlab. Sometimes, I can't see what's
The datepicker in jQueryUI renders with a dynamic position. It renders according to its
When you see Margin attribute in a XAML file of WPF, it has four

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.