teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

コード修正

2020/03/18 03:28

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ```html
13
13
  <div id="hero">
14
- <img class="ani" src="http://placehold.jp/400x600.png">
14
+ <img src="http://placehold.jp/400x600.png">
15
15
  </div>
16
16
  ```
17
17
 

1

コード追加

2020/03/18 03:28

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -4,4 +4,37 @@
4
4
 
5
5
  [【CSS】animation・keyframesを徹底解説 – WEBDESIGNDAY](https://webdesignday.jp/inspiration/pickup/5167/)
6
6
 
7
- [animation - CSS: カスケーディングスタイルシート | MDN](https://developer.mozilla.org/ja/docs/Web/CSS/animation)
7
+ [animation - CSS: カスケーディングスタイルシート | MDN](https://developer.mozilla.org/ja/docs/Web/CSS/animation)
8
+
9
+ ---
10
+ CSS animation のみで実現する方法です。
11
+
12
+ ```html
13
+ <div id="hero">
14
+ <img class="ani" src="http://placehold.jp/400x600.png">
15
+ </div>
16
+ ```
17
+
18
+ ```css
19
+ #hero img {
20
+ width: 400px;
21
+ height: 600px;
22
+ position: absolute;
23
+ bottom: -600px;
24
+ left: 0;
25
+ animation: up 4s linear 5s 3,
26
+ up2 2s linear 17s forwards;
27
+ }
28
+
29
+ @keyframes up {
30
+ 0% { bottom: -600px; }
31
+ 100% { bottom: 100vh; }
32
+ }
33
+
34
+ @keyframes up2 {
35
+ 0% { bottom: -600px; }
36
+ 100% { bottom: 0; }
37
+ }
38
+ ```
39
+
40
+ [Codepenサンプル](https://codepen.io/hatena19/pen/WNvypEz)