What other values are used on the position property?


#1

Question

What other values are used on the position property?

Answer

The position property takes many useful values including relative - the other position values that you’ll use most often are:

position: absolute;

  • removes the element from the normal flow of the document
  • can use positioning properties like top, right, bottom, and left
  • positioned in relation to the nearest positioned parent element
  • if there is no positioned parent element, the element is positioned in relation to the <html> element

and

position: fixed;

  • removes the element from the normal flow of the document
  • can use positioning properties like top, right, bottom, and left
  • positioned in relation to the viewport of the browser
  • not affected by scrolling (element stays “fixed” to where it’s positioned even when scrolling)