CSS - Positioning

Positioning

In this tutorial, I will be showing you the different property values that you can use to position your element in your webpage.

There are five (5) methods of positioning element in your HTML page: static, relative, absolute, fixed and sticky.
The position property is used to set position of the element in the web page.

Position Property Values

static - elements are positioned according to the normal flow of the web page. (It is not affected by the top, bottom, right, left & z-index properties).

relative - elements are positioned relative to its normal position. Here the top, bottom, right, left & z-index properties can be used to adjust its position.

absolute - elements are taken out of its normal flow and positioned relatived to the first parent element; whose positioning is not static. Here the top, bottom, right, left & z-index properties can be used to adjust its position.

fixed - elements remain in the same point or place on the screen even when you scroll up and down, left and right. Here the top, bottom, right, left & z-index properties can be used to adjust its position.

sticky - combination of both relative and fixed properties to make the element stick to the top of the web page - viewport, when you scroll through the page.

note
NOTE:

The top, right, bottom or left property must be specified for the sticky value to work.

ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT