Log In Registration

CSS Trick: Position Absolute Inside Relative

  • Sharebar

Beginners of Cascading Stylsheets (CSS) might not know this trick that I’m about to share.  The day you find out about ‘position: absolute’ is the day you will feel like you know CSS like the back of your hands.  But have you ever used this property and found out that the div box is not behaving as it should, e.g. the div’s absolute position is relative to the browser’s page and not the website’s container?

Example:

Box Position Relative To Browser Canvas

Box Position Relative To Browser Canvas

If that’s not the desired result, and you’re trying to obtain a result whereby the box is inside the container or inside another div (and the position is relative to that box), e.g.:

Box Position Relative To Selected Div (e.g. Container)

Box Position Relative To Selected Div (e.g. Container)

Then the solution is to add:

position: relative;

To the parent div, in this case the #container.

So if the absolute is inside the relative, then you will be able to have full control of the absolute – relative to its parent div.

Related posts:

  1. How To Edit WordPress Login Page
  2. Indian Ocean Island Games Seychelles 2011: Flags of Participating Countries
  3. HTML / CSS Vertical Menu Text With Text Buttons
  4. How To Create Custom-Shaped Pictures On Photoshop
  5. Gmail Allows You To Trace Email Source
This entry was posted in Tutorials and tagged , , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Support sabrinasabino.com!

No Comments

(Required)
(Required, will not be published)

CommentLuv badge

  • RSS Featured Software

  • Categories

  • Archives

  • About Me

    WYSIWYG! I'm a simple person trying to live the simplest life possible - it seems to be the most difficult thing to achieve! I'm an internet enthusiast and I've been a webmaster since early 2007. I like: blogging, developing sites using open source software, social media, computer games, '80s music, comedy & horror, animals, crunching on M&Ms peanut and Smarties!
More in Tutorials (36 of 78 articles)


When you think about the ability that GPS gives us to locate ourselves and others, pinpointing our location with amazing accuracy, it almost seems like magic. Of course, it is ...