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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:17:03+00:00 2026-06-08T13:17:03+00:00

Possible Duplicate: position: absolute without setting top/left/bottom/right? Looking at the following code, I have

  • 0

Possible Duplicate:
position: absolute without setting top/left/bottom/right?

Looking at the following code, I have div#box2 that has position: absolute set on it. It is in between two divs that have position: static set on them. Based on the following code, I would expect div#box2 to be at the top left of the body element. However, when it is rendered it receives a top value placing it beneath box1. Why does this happen?

I understand that when I explicitly set the top value of div#box2 to 0px, it appears at the top. I just don’t know why it is not computed to 0px by the browser to begin with.

Here is some sample code:

<!DOCTYPE html>
<html>
  <head>
    <title>Position Test</title>
    <style type="text/css">
      body { background-color: #DEDEDE; }
      #content { border: solid; }
      #content div { height: 150px; opacity: .7;}
      #box1 { background-color: red; }
      #box2 { background-color: yellow; }
      #box3 { background-color: lightblue; }

    #content div { width: 150px; }
        #box2 { position: absolute; text-align: right;}
    </style>
  </head>
  <body>
    <div id="content">
      <div id="box1"><span>1</span></div>
      <div id="box2"><span>2</span></div>
      <div id="box3"><span>3</span></div>
    </div>
  </body>
</html>
  • 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-08T13:17:05+00:00Added an answer on June 8, 2026 at 1:17 pm

    When an element is given position absolute it is taken out of the flow allowing other elements to be placed above or below it. Without explicitly setting a top value, the top value will retain the elements position had it not be removed from the flow.

    If we switch the order of the boxes you can see this taking place as #box2 is completely removed from the flow and sits outside of #content but still stacks where it would be if it had position:static

    <!DOCTYPE html>
    <html>
      <head>
        <title>Position Test</title>
        <style type="text/css">
          body { background-color: #DEDEDE; }
          #content { border: solid; }
          #content div { height: 150px; opacity: .7;}
          #box1 { background-color: red; }
          #box2 { background-color: yellow; }
          #box3 { background-color: lightblue; }
    
        #content div { width: 150px; }
            #box2 { position: absolute; text-align: right;}
        </style>
      </head>
      <body>
        <div id="content">
          <div id="box1"><span>1</span></div>
          <div id="box3"><span>3</span></div>
          <div id="box2"><span>2</span></div>
    
        </div>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: UIImage position I'm using the following code to place some images in
Possible Duplicate: JavaScript: Scroll Position of div with “overflow: auto” Hi, i want to
Possible Duplicate: How to show/hide a div on mouseover using jquery? I have a
Possible Duplicate: How to recalculate correct position I have been trying to achive this
Possible Duplicate: How to get the mouse position without events (without moving the mouse)?
Possible Duplicate: Stop default hashtag behavior with jquery I have some jquery code on
Possible Duplicate: Position an element from the end of the document at the top
Possible Duplicate: Find position of element in C++11 range-based for loop? I have a
Possible Duplicate: CSS: fixed position on x-axis but not y? I have a HTML
Possible Duplicate: CKEditor - Set cursor position to end of text I have a

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.