The Golden Rule
🏠 Positioning (top, left, etc.)
👉 Moves relative to the PARENT
🚶 Translate (translate-x, translate-y)
👉 Moves relative to ITSELF
That’s it.
If you remember only this, you’ll never confuse them again.
🎯 Imagine This Real-Life Story
Think of a room (parent) and a table (element).
1️⃣ left-1/2 → Parent Based
You tell someone:
“Put the table so its left edge is at 50% of the room.”
The room decides the position.
So positioning = 📏 Room measurement
2️⃣ translate-x-1/2 → Self Based
Now you say:
“Move the table forward by half of its own width.”
The table measures itself.
So translate = 📦 Self measurement
🔥 Ultimate Memory Formula
💡 Why Centering Needs Both
When you do:
You move the left edge to center.
But the element is not centered — only its edge is.
So you fix it using:
Which means:
“Okay element, now move yourself back by half your own width.”
That balances it perfectly.
🧠 Visual Brain Trick
Whenever confused, ask yourself:
👉 “Who is measuring the distance?”
If answer is:
-
Parent → positioning
-
Element itself → translate
⚡ One-Line Memory Hack
Position pushes from outside.
Translate shifts from inside.
Comments
Post a Comment