+ 2

[CSS]🎨 Question: Relative and Fixed position?

I was working on a code in web. Meanwhile I used position attribute and discovered that there are two types of value for position viz. fixed and relative (Absolute is also) I want to know what is exactly the difference between both of them, relative and fixed positioning? Thank you!

11th Dec 2017, 12:07 PM
#RahulVerma
#RahulVerma - avatar
2 Answers
+ 8
Relative property of positioning is used for some content we don't want to determines its top, bottom, left and right. It will be fixed to nearest parent element. Whereas, In fixed property of positioning it is been nearest to the viewport where it is fixed. Even on the scrolling of the page it will not move from it's place.
11th Dec 2017, 12:23 PM
Akash Pal
Akash Pal - avatar
+ 5
Check the difference with example. https://www.w3schools.com/css/css_positioning.asp
11th Dec 2017, 12:25 PM
Ranjan Bagri
Ranjan Bagri - avatar