Hi,
whilst working on the animation section of the Full Stack course, I came across this page:
It gives the example as:
img {
transform: translate(150px);
width: 80%;
}
...
However, the course would only accept the X on the end of translate:
img {
transform: translateX(150px);
width: 80%;
}
I assume the X is the correct way and the other is an error?
Davie.x
The translate() method accepts two values corresponding to x and y axes. When only one value is supplied, the y value defaults to 0.
The translateX() and translateY() methods specifically relate only to their corresponding axes.
So, in effect, translate(150px) is identical to translateX(150px).
Yes, translateX(150px) is the correct way to move an element along the X-axis. translate(150px) is shorthand for translate(150px, 0), but specifying translateX makes it clearer. Good catch!