Elements positioned relatively are situated in relation to their default location — revolving around themselves. Elements with relative positioning open up possibilities for placement while keeping their initial location intact within the document flow.
After assigning a relative position to an element, you can use values that are relative to its starting point for top, bottom, left, or right. Additionally, you have the option to modify its z-index value.
Outlined in this tutorial:
- Overlay of an element
- Subordinate placement of an element
Overlay of an element
- Choose the element you wish to overlay
- Create a customized class (e.g., “special”)
- Set the positioning to relative (this will enable z-index adjustment)
- Now, you can alter the position independently of other elements, causing it to appear in front of the default content
Subordinate placement of an element
- Select the element you want to position underneath
- Generate a customized class (e.g., “super”)
- Apply relative positioning (to enable z-index customization)
- Assign a numerical value (greater than 0, in this particular scenario)
- In the preceding step, assign a higher or lower value to the element to either place it on top or behind
Relative positioning enables you to position elements in relation to their original placement independently from surrounding content on the page.
Latest posts by Ewan Mak (see all)
- Include or eliminate Workspace spots and members - April 15, 2024
- Centering box summary - April 15, 2024
- Store a site for future reference - April 15, 2024