1

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?

6
  • 3
    There's plenty of documentation on this subject. Please read it before posting questions here :) developer.mozilla.org/en/docs/Web/CSS/position Commented Apr 5, 2017 at 3:58
  • Also, go check out w3schools.com/css. Commented Apr 5, 2017 at 4:00
  • I already read, before posting question here Commented Apr 5, 2017 at 4:02
  • then should go through them again, try to explore some examples to understand the difference. Commented Apr 5, 2017 at 4:07
  • hmmmmmm.. OK. Thanks for your advice Commented Apr 5, 2017 at 4:26

1 Answer 1

2

Here you can understand the basic difference between the css poisitions


enter image description here

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.