LoginSignup
1
1

More than 3 years have passed since last update.

【CSS】transition

Posted at

transition

:sunny: マウスのポインタを要素の上に置いたときに変化する時間を指定できる
:sunny: 多くの場合は hover と一緒に使用する

【CSS】hover のときに下記の動画を載せました。

ezgif.com-crop (1).gif

これに transition を追加して少し変化を加えてみたいと思います:smile:

例.css
p:hover {
  background-color: red;
}

p {
  transition: all 5s;
}

どうなるかというと・・・

ezgif.com-crop (1)のコピー.gif

背景色がゆ〜っくり変化しました:laughing:

セレクタ {
  transition: 変化の対象 変化にかかる時間;
}

となります:smile:
今回でいえば

変化の対象 ・・・ all
変化にかかる時間 ・・・ 5s

です。

all は指定したセレクタ全て変化させます。
反対に none だと変化させない設定にできます。

5s は 5秒かけて変化し 5秒かけて戻ります。
5s の s は second(秒) の s です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1