In-Depth Guide to Understanding Positioning in CSS !!๐
We'll focus on the CSS position property here. We are going to learn the various values of the CSS position property. So let's Rock & Roll ๐โ๐
The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final location of positioned elements.
Types of Positioning in CSS ๐: Position: static; Position: relative; Position: absolute; Position: fixed; Position: sticky;
Types of Positioning in CSS (Global values) ๐:
Position: inherit;
Position: initial;
Position: revert;
Position: revert-layer;
Position: unset;
โ Static : The element is positioned according to the normal flow of the document. The top, right, bottom, left, and z-index properties have no effect. This is the default value.
โ Relative : The element is positioned according to the normal flow of the document, and then offset relative to itself based on the values of top, right, bottom, and left.
โ Absolute : The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to its closest positioned ancestor, if any; otherwise, it is placed relative to the initial containing block. Its final position is determined by the values of top, right, bottom, and left.
โ 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.
โ Sticky A sticky element toggles between relative and fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (position:fixed).
To conclude, we have got these many Types and Properties of positioning in CSS. & Yay ๐! That has been quite a ride. But I really hope this article helped you understand the CSS position property and how it works.
Remember CSS is all about practice, So keep hustling with constant practice, you'll definitely get better. ๐๐๐๐