LoginSignup
7
6

More than 5 years have passed since last update.

【CSS】背景のアニメーション

Posted at

とある要素にhoverしたとき、背景画像をちょっと大きくしたいなと思ったので

a {
  background-size: auto 100%;
  transition: 0.3s;
}
a:hover {
  background-size: auto 110%;
}

(ベンダープレフィックス、その他の要素は省略)

としてたのですがががが。。。
IE11が動かないorz

ほかのCSSアニメーションは何の違和感もなく動いているのに、background-sizeだけは反応してくれない
スムーズな動きは全くなく、transitionなんて無かったかのようにカクカク動きやがる
IEなんて無くなればい(ry

さてどうしたもんか
ここでjsを使うのもなぁ、、、ということで
scaleで対処することにしました

a img {
  transform : scale(1);
  transition: 0.3s;
}
a:hover img {
  transform : scale(1.1);
}

これでIE11でも問題なく動いてくれましたとさまる

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