Positions

The following blog post will based on how the CSS property, positions can be applied In HTML and CSS. CSS Positions specify how an element is to be positioned on a html page, the most commonly used positions being static, relative, absolute, sticky etc. It will be briefly explained what each position does and how that position can be utzlied by a developer when building a page on a website.

Position static

Position static is the default position for HTML elements, position static essentially means that an element is not to be positioned in any radical or special way and goes with HTMLs normal document flow.

Position Relative

To make things easier think of the technical term of Position relative as a posh way of saying based of its previous position, you can base an elements new position relatively by using top right, bottom, and left property and providing a distance, for example if you were to code (demonstration with an explanation below or to right if depending on screen size).

This element has relative positioning applied to it but cannot change position until it is told where to move for example 30px to the left.

The element has now been moved relatively 30px to the left

Position Absolute

Position absolute works In the exact same way as position relative does except that any element that is positioned absolute will look for the nearest element that is positioned relative so It can base Its position off it.(demonstration with an explanation below or to right if depending on screen size). if an element that is positioned absolute has no relatively positioned parent elements it will use the document body to base its position off.

As can be seen the absolute element has positioned itself based off the relatively positioned element, but has been moved away.

Position Sticky

Position Sticky Is a css position property that Is typically used to make an element stick and move along with the screen when a user scrolls down a page (demonstration with an explanation below or to right if depending on screen size).

The video above shows how position sticky works, as can be seen the element on the top of the page sticks when the user scrolls.

Conclusion

Thank you for viewing this blog post, I hope this blog has given you a better idea about CSS positions. If you feel asif you you need to require more information about this topic I would recommend watching youtube tutorials and view other resources such as W3Schools.