Can any one tell me the Difference between style = "position:absolute"
and style = "position:relative"
and how they differ in case I add it to div
/span
/input
elements?
I am using absolute
right now, but I want to explore relative
as well. How will this change the positioning?
OK, very obvious answer here... basically relative position is relative to previous element or window, while absolute don't care about the other elements unless it's a parent if you using top and left...
Look at the example I create for you to show the differences...
Also you can see it in action, using the css I create for you, you can see how absolute and relative positions behave:
With CSS positioning, you can place an element exactly where you want it on your page.
When you are going to use CSS positioning, the first thing you need to do is use the CSS property position to tell the browser if you're going to use absolute or relative positioning.
Both Postion are having different features.In Css Once you set Position then you can able to use top,right,bottom,left attributes.
Absolute Position
An absolute position element is positioned relative to the first parent element that has a position other than static.
Relative Position
A relative positioned element is positioned relative to its normal position.
To position an element relatively, the property position is set as relative. The difference between absolute and relative positioning is how the position is being calculated.
More :Postion Relative vs Absolute
Absolute positioning is based on co-ordiantes of the display:
^ places the element top left of the window.
Relative position is relative to where the element is placed:
^ places the element 1px down and 1px from the left of where it originally sat :)