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

質問編集履歴

1

試したコードを記載しました。

2023/12/24 08:31

投稿

Shinnosuke0128
Shinnosuke0128

スコア4

title CHANGED
File without changes
body CHANGED
@@ -32,12 +32,102 @@
32
32
  </div><!-- wrapper -->
33
33
 
34
34
  <script>
35
+ const targettargetElement = document.getElementById("button");
35
36
  function fadeAnimation() {
37
+ targettargetElement.style.transition = "opacity 1s";
38
+ let sw = 0 //
36
39
  }
40
+ function fadeSwitch(){
41
+ if(sw == 1){
42
+ fadeIn();
43
+ sw = 0;
44
+ }
45
+ else if(sw == 0){
46
+ fadeOut();
47
+ sw = 1;
48
+ }
49
+ }
50
+ function fadeIn() {
51
+ targettargetElement.style.transition = "opacity 2s"; // 1
52
+ targettargetElement.style.opacity = "1"; // 1
53
+ }
54
+ function fadeOut() {
55
+ targettargetElement.style.opacity = "0"; // 1
56
+ }
57
+ // setInterval fadeSwitch 2
58
+ setInterval(fadeSwitch, 2000);
59
+
37
60
  </script>
38
61
  </body>
39
62
  </html>
63
+ ```
64
+ ```css
65
+ @charset "UTF-8";
66
+ /* reset */
67
+ body, h1, h2, h3, h4, h5, h6, p, address,
68
+ ul, ol, li, dl, dt, dd, img, form, table, tr, th, td {
69
+ margin: 0;
70
+ padding: 0;
71
+ border: none;
72
+ font-style: normal;
73
+ font-weight: normal;
74
+ font-size: 100%;
75
+ text-align: left;
76
+ list-style-type: none;
77
+ border-collapse: collapse;
78
+ }
40
79
 
80
+ textarea { font-size: 100%; vertical-align:middle;}
81
+ img { border-style: none; display: block; }
82
+ hr { display: none; }
83
+ em{font-style: normal}
84
+ input{line-height:auto;vertical-align:middle;}
85
+ strong.more{color:#c30}
86
+ a{text-decoration: none;}
87
+
88
+ html {
89
+
90
+ }
91
+
92
+ body {
93
+ font-family:'ヒラギノ角ゴ Pro W3','Hiragino Kaku Gothic Pro','メイリオ',Meiryo,'MS Pゴシック',sans-serif;
94
+ }
95
+
96
+ * {
97
+ -webkit-box-sizing: border-box;
98
+ -moz-box-sizing: border-box;
99
+ -o-box-sizing: border-box;
100
+ -ms-box-sizing: border-box;
101
+ box-sizing: border-box;
102
+ }
103
+
104
+ /* 上の部分は気にせずここから書く */
105
+ #wrapper {
106
+ height: 100vh;
107
+ display: flex;
108
+ justify-content: center;
109
+ align-items: center;
110
+ }
111
+
112
+ .box {
113
+ display: flex;
114
+ flex-direction: column;
115
+ }
116
+
117
+ #button {
118
+ width: 200px;
119
+ height: 60px;
120
+ background-color: #fdd;
121
+ border: none;
122
+ margin: 0 auto 20px;
123
+ cursor: pointer;
124
+ }
125
+
126
+ #image {
127
+ width: 300px;
128
+ opacity: 1;
129
+ }
130
+
41
131
  ```
42
132
 
43
133
  ### 試したこと