Absolute, Relative, Fixed and Sticky properties in CSS

Ankur KashyapAnkur Kashyap
1 min read

By default position is static.

Static: No difference can be seen.

Relative: Relative to its normal position. If top, left are present then the div will move according to the top and left value from its normal position.

Absolute: The div will move with respect to its parent(parent can be its parent div and if not then body is the parent). Now div will not move with respect to its normal position.

Sticky: It means the div is fixed at a particular position even if we scroll. It will not leave its original position.

Fixed: It means div leaves its position and if another div is present next to it, that second div will take its position and the fixed div will come above the second div and is fixed at a particular position even if we scroll.

0
Subscribe to my newsletter

Read articles from Ankur Kashyap directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ankur Kashyap
Ankur Kashyap

I am a Software Engineer