translateY()

translateY()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> です。直交座標系では Y 座標の移動量をを表します。パーセント値は 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

関連情報