What are the differences between relative, absolute, and fixed positioning?
Relative Positioning:
Imagine you have a picture on a wall. You want to move it a little to
the right or down from where it originally hangs. It’s still
attached to the same spot on the wall, but just shifted.
Example: Think of a book on a shelf. If you move it a bit to the left or right from where it was, that’s like relative positioning. It’s still in the same general place on the shelf but just adjusted from its original position.
BOOK SHELF
Absolute Positioning:
Now, picture that you have a picture frame, and you decide exactly where to put it on the wall, like 10 inches from the top and 20 inches from the left. It’s not moving relative to other things but fixed in a specific spot.
Example: Imagine a poster on a wall where you put a sticker exactly 5 inches from the top and 10 inches from the side. No matter how you move or adjust things around it, that sticker stays in that exact spot.
Frame
I am a WALL
Fixed Positioning:
Think of having a floating sign on your car's windshield that stays in the same spot no matter how you drive. Even if you turn or stop, the sign stays in the same spot on the windshield.
Example: Imagine this entire page as a car and the area where you read this text as the windshield. If you place a stop sign on the windshield, it will remain visible no matter if you scroll up or down; you'll always see the stop sign.