CSS right property is used to specify the horizontal position of an element.
Depending on the parent container, CSS right property works differently,
- If the position is absolute or fixed, the right property denotes the space between the containers right end and the elements right end.
- If the position is relative, the right property denotes that the element is moved to the left side from the given position.
- If the position is sticky, and if the element is inside the container it acts similar to relative, else if it is outside the container it works similar to the fixed.
- If the position is static, the right property has no effect on the element.
Example 1 - right value while position is absolute
Example 2 - right value while position is relative
Example 3 - right value while position is sticky