translateY()

translateX()CSS関数で、要素を二次元平面上の水平方向で再配置します。結果は <transform-function> データ型になります。

メモ: translateY(ty)translate(0, ty) または translate3d(0, ty, 0) と等価です。

構文

css

/* <length-percentage> 値 */
transform: translateY(200px);
transform: translateY(50%);

<length-percentage>

変換ベクトルの縦座標を表す <length> または <percentage> です。パーセント値は transform-box プロパティで定義される参照ボックスの幅からの相対値です。

ℝ^2 のデカルト座標 ℝℙ^2 の同次座標 ℝ^3 のデカルト座標 ℝℙ^3 の同次座標

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

1 0 0 0 1 t 0 0 1 1 0 0 0 1 t 0 0 1 1 0 0 0 0 1 0 t 0 0 1 0 0 0 0 1
[1 0 0 1 0 t]

形式文法

css

translateY(<length-percentage>)

HTML

html

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

CSS

css

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

.moved {
  transform: translateY(10px);
  background-color: pink;
}

結果

仕様書

Specification
CSS Transforms Module Level 1
# funcdef-transform-translatey

ブラウザーの互換性

BCD tables only load in the browser

関連情報