Jump to content

Absolute relative confusion


chemo

Recommended Posts

In my experience, absolutely positioned elements are sort of removed from the rest of the content and placed in their own layer. Relatively positioned elements stay with the rest of the content.Look at how these two pages differ when viewed in a browser:RELATIVE:

<html><head><style type="text/css">div { width: 200px; height: 200px; }#block1{ background-color: #cccccc; position: relative; left: 40px; }#block2{ background-color: #ffff8c;}</style></head><body><div id="block1">This is div one.</div><div id="block2">This is div two.</div></body></html>

ABSOLUTE:

<html xmlns="http://www.w3.org/1999/xhtml" ><head><style type="text/css">div { width: 200px; height: 200px; }#block1{ background-color: #cccccc; position: absolute; left: 40px; }#block2{ background-color: #ffff8c;}</style></head><body><div id="block1">This is div one.</div><div id="block2">This is div two.</div></body></html>

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...