0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JSを使わず、animationプロパティを使ってマウスホバー時のスライドを作りました

Posted at

JSを使わず  animationプロパティを使ってマウスホバーした時画像がスライドするを作ってみました。

codepenでコードを書いてみました

See the Pen VwpazmV by トモゑ☛Web作成の37🌺 (@swan2pink) on CodePen.

.main1 {
  position: relative;
  width: 300px;
  height: 300px;
  overflow: hidden; 
}
.second {
  position: absolute;
  top: 0;
  left: 0;
}

@keyfram でスライドした際の画像格納場所をどうすれば良いかを悩みました。
結果、overflow: hiddenを親要素につけたら上手に納まりました。

参考資料
[overflow:hiddenやscrollが効かない原因と対応方法] (https://csshtml.work/overflow-bad/)

まとめ

こんなcodeもシンプルで良いですよとかありましたらご連絡ください
とっても喜びます!

今回は以上です
ありがとうございます!!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?