I am new in CSS. I'm trying to understand, but I can not. Please, explain me about position(absolute,fixed,relative,static). What is where used?
-
3There's plenty of documentation on this subject. Please read it before posting questions here :) developer.mozilla.org/en/docs/Web/CSS/positionShadow– Shadow2017-04-05 03:58:22 +00:00Commented Apr 5, 2017 at 3:58
-
Also, go check out w3schools.com/css.user4616966– user46169662017-04-05 04:00:17 +00:00Commented Apr 5, 2017 at 4:00
-
I already read, before posting question hereQandroid– Qandroid2017-04-05 04:02:08 +00:00Commented Apr 5, 2017 at 4:02
-
then should go through them again, try to explore some examples to understand the difference.bhansa– bhansa2017-04-05 04:07:30 +00:00Commented Apr 5, 2017 at 4:07
-
hmmmmmm.. OK. Thanks for your adviceQandroid– Qandroid2017-04-05 04:26:48 +00:00Commented Apr 5, 2017 at 4:26
1 Answer
Here you can understand the basic difference between the css poisitions
position: static;
Static positioned elements are not affected by the top, bottom, left, and right properties.
An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page.
position: relative;
An element with position: relative; is positioned relative to its normal position.
Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.
position: fixed;
An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element.
position: absolute;
An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.