Wednesday, November 21, 2012

Css Positions

You can put any HTML element at wherever position in the page or absolute based on its parent element.

Relative Positioning:
It changes the position of the HTML element relative to where it normally appears
For example:
<div style=”position:relative;left:80px; top:2px; background-color:yellow;”>
This div has relative positioning
</div>



Absolute Positioning:
An element with position absolute is positioned at the specified coordinates relative to your screen top left corner.
For example:
<div style=”position:absolute; left:80px; top:20px; background-color:yellow:”>
This is absolute positioning.
</div>

Fixed Positioning:
This allows you to fix the position of an element to the browzer window.
For example:
<div style=”position:fixed; left:80px; top:20px; background-color:yellow;”>
This is fixed positioning.
</div>

No comments:

Post a Comment