Friday, 30 May 2008

CSS: Relatively Positioned DIV

A relatively positioned div is said to be in the document flow. As such, our blue div will now occupy space at the page level, and its existence will have an effect on surrounding elements.The flow is based on code order in your source code.

#blue {
width: 100px;
height: 100px;

top: 0;
left: 0;

position: relative;
background-color: blue;
margin: 0;
}

h1 {
border: 1px solid #000;
margin: 0;
}

Spotting the difference
Image 1: Relative and Absolute positioning. Both divs are set at top 0 & left 0

Both our relative and absolutely positioned divs will respond to margin settings, including negative values.

http://www.communitymx.com/content/article.cfm?page=2&cid=3B56F

No comments: