The translate() CSS function is used to reposition an element to the top, bottom, right, left, front and back directions. The value can be in px, in, cm, em, %, etc., okay. However, the translateZ() doesn't support the value in percentage (%).
The translateX() CSS function moves an element horizontally to the left or right direction. The negative value will shift the element toward the left direction and the positive value will shift the element toward the right direction.
TranslateX() examples which are all same: translateX(30px) = translate(30px) = translate(30px, 0) = translate3d(30px, 0, 0)
TranslateY(): The translateY() CSS function moves an element vertically to the bottom or top direction. The negative value will shift the element toward the top direction and the positive value will shift the element toward the bottom direction.
TranslateY() examples which are all same: translateY(80px) = translate(0, 80px) = translate3d(0, 80px, 0)
Translate(x, y): We can write the translate X & Y at a time.
Translate(x, y) examples which are all same: translate(1cm, -80%) = translateX(1cm) translateY(-80%) = translate(1cm) translateY(-80%) = translate3d(1cm, -80%, 0)
TranslateZ(): The translateZ() CSS function moves an element to the front or back direction in a 3D view. The negative value will shift the element toward the back direction and the positive value will shift the element toward the front direction.
TranslateZ() examples which are all same: translateZ(1.2in) = translate3d(0, 0, 1.2in)
Translate3d(x, y, z):
The translate3d() CSS function moves an element along the X, Y & Z axes in a 3D space. It is just like a shorthand method of writing all the translate X, Y & Z together. To make the object move closer or further, we can link the perspective() function with the translate Z. Make sure the perspective() function is written before the translate() function. The negative Z value will push the object further. The positive Z value will make the object come closer. As we learned at the beginning, the x value will move the element to the right or left direction and the y value will move the element to the bottom or top direction.
Translate3d(x, y, z) examples, which are all same: translate3d(50px, -5ch, 50em) = translateX(50px) translateY(-5ch) translateZ(50em) = translate(50px) translateY(-5ch) translateZ(50em) = translate(50px, -5ch) translateZ(50em)