LoginSignup
0
0

More than 5 years have passed since last update.

positon:ralativeやabsoluteを使ってtransitonする時の注意点

Last updated at Posted at 2019-04-01

変更前に初期値を設定する必要がある

これだと動かない

.btn{
  background: red;
  transition: all 1s;
}

.btn:hover{
  cursor: pointer;
  background: red;
  transition: all 1s;
  position: relative;
  top: 10px;
}

これで動く

.btn{
  background: red;
  transition: all 1s;
  position: relative;//初期値
  top: 0;//初期値
}

.btn:hover{
  cursor: pointer;
  background: red;
  transition: all 1s;
  top: 10px;//変更後
}

0
0
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
0
0