--- title: translate3d() slug: Web/CSS/transform-function/translate3d() tags: - CSS - CSS Function - CSS Transforms - Function - Reference translation_of: Web/CSS/transform-function/translate3d() ---
{{CSSRef}}

translate3d()CSS関数で、要素を 3D 空間内で再配置します。返値は {{cssxref("<transform-function>")}} データ型です。

{{EmbedInteractiveExample("pages/css/function-translate3d.html")}}

この変換は三次元ベクトルであることが特徴です。座標は要素がそれぞれの方向にどれだけ移動するかを定義します。

構文

translate3d(tx, ty, tz)

tx
変換ベクトルの横座標を表す {{cssxref("<length>")}} または {{cssxref("<percentage>")}} です。
ty
変換ベクトルの縦座標を表す {{cssxref("<length>")}} または {{cssxref("<percentage>")}} です。
tz
変換ベクトルの z 成分を表す {{cssxref("<length>")}} です。 {{cssxref("<percentage>")}} 値は指定できません。この場合、これを含む変換は無効とされます。
2 のデカルト座標 ℝℙ2 の同次座標 3 のデカルト座標 ℝℙ3 の同次座標

2 では線形変換ではないので、デカルト座標の行列で表すことはできない。

3 では線形変換ではないので、デカルト座標の行列で表すことはできない。 100tx010ty001tz0001

単一軸を使用した変換

HTML

<div>Static</div>
<div class="moved">Moved</div>
<div>Static</div>

CSS

div {
  width: 60px;
  height: 60px;
  background-color: skyblue;
}

.moved {
  /* Equivalent to perspective(500px) translateX(10px) */
  transform: perspective(500px) translate3d(10px, 0, 0px);
  background-color: pink;
}

結果

{{EmbedLiveSample("Using_a_single_axis_translation", 250, 250)}}

z 軸と x 軸を組み合わせた変換

HTML

<div>Static</div>
<div class="moved">Moved</div>
<div>Static</div>

CSS

div {
  width: 60px;
  height: 60px;
  background-color: skyblue;
}

.moved {
  transform: perspective(500px) translate3d(10px, 0, 100px);
  background-color: pink;
}

結果

{{EmbedLiveSample("Combining_z-axis_and_x-axis_translation", 250, 250)}}

仕様書

仕様書 状態 備考
{{SpecName("CSS Transforms 2", "#funcdef-translate3d", "translate3d()")}} {{Spec2("CSS Transforms 2")}} 初回定義

ブラウザーの互換性

<transform-function> データ型の互換性情報をご覧ください。

関連情報