I always see code like this:
#container {
background:#000000 none repeat scroll 0 0;
display:block;
overflow:hidden;
position:relative;
width:100%;
}
I thought position relative is used to accommodate the div relatively to its parent element using the CSS proprieties left right top and bottom (px). What’s the point of using it alone like the example below? Which other properties are being affected by position relative?
Child elements position can get affected by this.
After setting parent elements position to relative, when we try to set the child elements position to be absolute then it will be absolutely placed relative to the parent only and not to the document.
First example
Second Example
Try to check the above two examples and you will see the difference.