--- title: translate3d() slug: Web/CSS/transform-function/translate3d() tags: - CSS - CSS Function - CSS Transforms - Function - Reference translation_of: Web/CSS/transform-function/translate3d() ---
translate3d()
は CSS の関数で、要素を 3D 空間内で再配置します。返値は {{cssxref("<transform-function>")}} データ型です。
このデモのソースファイルは GitHub リポジトリに格納されています。デモプロジェクトに協力したい場合は、 https://github.com/mdn/interactive-examples をクローンしてプルリクエストを送信してください。
この変換は三次元ベクトルであることが特徴です。座標は要素がそれぞれの方向にどれだけ移動するかを定義します。
translate3d(tx, ty, tz)
tx
ty
tz
ℝ2 のデカルト座標 | ℝℙ2 の同次座標 | ℝ3 のデカルト座標 | ℝℙ3 の同次座標 |
---|---|---|---|
ℝ2 では線形変換ではないので、デカルト座標の行列で表すことはできない。 |
ℝ3 では線形変換ではないので、デカルト座標の行列で表すことはできない。 |
<div>Static</div> <div class="moved">Moved</div> <div>Static</div>
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)}}
<div>Static</div> <div class="moved">Moved</div> <div>Static</div>
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>
データ型の互換性情報をご覧ください。