CSS translate Property

❮ Previous Reference Next ❯

Example

.wrapper {
  perspective: 100px;
  display: inline-flex;
  gap: 1em;
}

.wrapper > div {
  width: 7em;
  line-height: 7em;
  text-align: center;
  transition: 0.5s ease-in-out;
  border: 3px dotted;
}

#box1:hover {
  translate: 20px;
}

#box2:hover {
  translate: 20px 20px;
}

#box3:hover {
  translate: 5px 5px 30px;
}

Meaning:

The translate CSS property specify translation transforms individually and independently of the transform property.

This maps better to typical user interface usage, and saves having to remember the exact order of transform functions to specify in the transform value.

Default value:none
Inherited:No
Animatable:Yes
Version:CSS3
JavaScript syntax:
object.style.translate="none|[length|percentage]|initial|inherit|revert|revert-layer|unset";



Standard Syntax

translate: none|[length|percentage]|initial|inherit|revert|revert-layer|unset;



Browser Support




Status







Property Values

The following table describes the values of this property:

Value Description
none Specifies that no translation should be applied.
[length|percentage] Specifies value in length or percentage.

Possible values:

  • Single value - A length or percentage that specifies a translation along the X-axis. Equivalent to a translate() (2D translation) function with a single value specified.
  • Two values - Two length or percentage that specify the X and Y axis translation values (respectively) of a 2D translation. Equivalent to a translate() (2D translation) function with two values specified.
  • Three values - Two length-percentage and single length values that specify the X, Y, and Z axis translation values (respectively) of a 3D translation. Equivalent to a translate3d() (3D translation) function.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  translate: none;
}
❮ Previous Reference Next ❯