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

質問編集履歴

1

インデント

2018/10/26 06:42

投稿

nonnon8.
nonnon8.

スコア19

title CHANGED
File without changes
body CHANGED
@@ -11,17 +11,17 @@
11
11
 
12
12
  <html>
13
13
  <head>
14
- <meta charset="utf-8">
14
+  <meta charset="utf-8">
15
- <title>game</title>
15
+  <title>game</title>
16
16
  <style>
17
17
  #ball{
18
- width:50px;
18
+  width:50px;
19
- height:50px;
19
+  height:50px;
20
- border-radius:50%;
20
+  border-radius:50%;
21
- top:300px;
21
+  top:300px;
22
- left:300px;
22
+  left:300px;
23
- background-color:black;
23
+  background-color:black;
24
- position:absolute;
24
+  position:absolute;
25
25
  }
26
26
 
27
27
  </style>
@@ -29,34 +29,33 @@
29
29
  </head>
30
30
 
31
31
  <body>
32
- <div id="ball"></div>
32
+  <div id="ball"></div>
33
33
 
34
- <input type="button" value="up" id="up" onclick="up()">
34
+  <input type="button" value="up" id="up" onclick="up()">
35
-
36
35
  </body>
37
36
 
38
37
  <script>
39
- function up(){
38
+  function up(){
40
- var ball=document.getElementById("ball");
39
+  var ball=document.getElementById("ball");
41
40
 
42
- var dis=Math.floor(Math.random()*300);
41
+  var dis=Math.floor(Math.random()*300);
43
- var dis1=10;
42
+  var dis1=10;
44
43
 
45
- var st=ball.style.top;
44
+  var st=ball.style.top;
46
45
 
47
- if(st<100){
46
+  if(st<100){
48
- ball.style.top=-dis;
47
+  ball.style.top=-dis;
49
48
 
50
49
 
51
- }else if(st>300){
50
+  }else if(st>300){
52
51
 
53
- alert("stop");
52
+  alert("stop");
54
- }else{
53
+  }else{
55
54
 
56
- ball.style.top=dis;
55
+  ball.style.top=dis;
57
- }
56
+  }
58
57
 
59
- };
58
+  };
60
59
 
61
60
  </script>
62
61
  </html>