Jump to content

Position : relative ?


terryds

Recommended Posts

Hey, i'm confused about position:relative ? What's the difference between position:static if i don't add the top or left or bottom, or right rule ?I often see most web designer use the position:relative without declaring the top,left,etc...Please tell me the difference !

Link to comment
Share on other sites

There are times you want to use position: relative to allow another element within it to be position: absolute. <body><div style="position: absolute; top: 100px; right: 0;">text NOT using relative</div> <div style="width: 500px; margin: 100px auto; position: relative; border: 1px solid #ff0000;"><div style="position: absolute; top: 100; right: 0;">text USING absolute contained with a div using relative</div></div></body> The first div tells it to be placed at the exact location on the screen. The second div is using relative and it will determine the second div that is using absolute to be placed precisely at that location within that containing div.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...