In-Depth Guide to Understanding Positioning in CSS !!๐Ÿ˜Ž

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 ๐Ÿ˜Žโ˜‘๐Ÿ‘‡

ยท

2 min read

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.

position.png

โœ… 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.

RELATIVE.png

โœ… 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.

ABSOLUTE.jpg

โœ… 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.

fixed.png

โœ… 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).

sticky.png

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. ๐Ÿ˜€๐Ÿ˜„๐Ÿ˜„๐Ÿ˜Ž

ย